• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Example for use of GNU gettext.
2# This file is in the public domain.
3#
4# Makefile configuration - processed by automake.
5
6# List of files which contain translatable strings.
7POTFILES = \
8  hello.tcl
9
10# Usually the message domain is the same as the package name.
11DOMAIN = $(PACKAGE)
12
13# These options get passed to xgettext.
14XGETTEXT_OPTIONS = --keyword=_ --flag=_:1:pass-tcl-format
15
16# This is the copyright holder that gets inserted into the header of the
17# $(DOMAIN).pot file.  Set this to the copyright holder of the surrounding
18# package.  (Note that the msgstr strings, extracted from the package's
19# sources, belong to the copyright holder of the package.)  Translators are
20# expected to transfer the copyright for their translations to this person
21# or entity, or to disclaim their copyright.  The empty string stands for
22# the public domain; in this case the translators are expected to disclaim
23# their copyright.
24COPYRIGHT_HOLDER = Yoyodyne, Inc.
25
26# This tells whether or not to prepend "GNU " prefix to the package
27# name that gets inserted into the header of the $(DOMAIN).pot file.
28# Possible values are "yes", "no", or empty.  If it is empty, try to
29# detect it automatically by scanning the files in $(top_srcdir) for
30# "GNU packagename" string.
31PACKAGE_GNU = no
32
33# This is the email address or URL to which the translators shall report
34# bugs in the untranslated strings:
35# - Strings which are not entire sentences, see the maintainer guidelines
36#   in the GNU gettext documentation, section 'Preparing Strings'.
37# - Strings which use unclear terms or require additional context to be
38#   understood.
39# - Strings which make invalid assumptions about notation of date, time or
40#   money.
41# - Pluralisation problems.
42# - Incorrect English spelling.
43# - Incorrect formatting.
44# It can be your email address, or a mailing list address where translators
45# can write to without being subscribed, or the URL of a web page through
46# which the translators can contact you.
47MSGID_BUGS_ADDRESS = bug-gettext@gnu.org
48
49# These options get passed to msgmerge.
50# Useful options are in particular:
51#   --previous            to keep previous msgids of translated messages,
52#   --quiet               to reduce the verbosity.
53MSGMERGE_OPTIONS = --quiet
54
55# These options get passed to msginit.
56# If you want to disable line wrapping when writing PO files, add
57# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and
58# MSGINIT_OPTIONS.
59MSGINIT_OPTIONS =
60
61MSGMERGE = @MSGMERGE@
62MSGMERGE_UPDATE = @MSGMERGE@ --update
63MSGMERGE_FOR_MSGFMT_OPTION = @MSGMERGE_FOR_MSGFMT_OPTION@
64MSGINIT = msginit
65MSGCONV = msgconv
66MSGFILTER = msgfilter
67
68# This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
69POTFILES_DEPS = @POTFILES_DEPS@
70
71# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po)
72POFILES = @POFILES@
73# This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update)
74UPDATEPOFILES = @UPDATEPOFILES@
75# This is computed as $(foreach lang, $(LINGUAS), $(lang).nop)
76DUMMYPOFILES = @DUMMYPOFILES@
77# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(frob $(lang)).msg)
78MSGFILES = @MSGFILES@
79
80# This is computed as
81# $(foreach lang, user-specified subset of $(LINGUAS), $(frob $(lang)).msg)
82CATALOGS = @TCLCATALOGS@
83
84SUFFIXES = .sed .sin .nop .po-create .po-update
85
86# The .pot file, stamp-po, .po files, and .msg files appear in release tarballs.
87# The GNU Coding Standards say in
88# <https://www.gnu.org/prep/standards/html_node/Makefile-Basics.html>:
89#   "GNU distributions usually contain some files which are not source files
90#    ... . Since these files normally appear in the source directory, they
91#    should always appear in the source directory, not in the build directory.
92#    So Makefile rules to update them should put the updated files in the
93#    source directory."
94# Therefore we put these files in the source directory, not the build directory.
95
96.sin.sed:
97	sed -e '/^#/d' $< > t-$@
98	mv t-$@ $@
99
100
101all-local: all-local-@USE_NLS@
102
103all-local-yes: $(srcdir)/stamp-po
104all-local-no:
105
106# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
107# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
108# we don't want to bother translators with empty POT files). We assume that
109# LINGUAS is empty in this case, i.e. $(POFILES) and $(MSGFILES) are empty.
110# In this case, $(srcdir)/stamp-po is a nop (i.e. a phony target).
111
112# $(srcdir)/stamp-po is a timestamp denoting the last time at which the CATALOGS
113# have been loosely updated. Its purpose is that when a developer or translator
114# checks out the package from a version control system, and the $(DOMAIN).pot
115# file is not under version control, "make" will update the $(DOMAIN).pot and
116# the $(CATALOGS), but subsequent invocations of "make" will do nothing. This
117# timestamp would not be necessary if updating the $(CATALOGS) would always
118# touch them; however, the rule for $(POFILES) has been designed to not touch
119# files that don't need to be changed.
120$(srcdir)/stamp-po: $(srcdir)/$(DOMAIN).pot
121	test ! -f $(srcdir)/$(DOMAIN).pot || \
122	  test -z "$(MSGFILES)" || $(MAKE) $(MSGFILES)
123	@test ! -f $(srcdir)/$(DOMAIN).pot || { \
124	  echo "touch $(srcdir)/stamp-po" && \
125	  echo timestamp > $(srcdir)/stamp-poT && \
126	  mv $(srcdir)/stamp-poT $(srcdir)/stamp-po; \
127	}
128
129# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
130# otherwise packages like GCC can not be built if only parts of the source
131# have been downloaded.
132
133# This target rebuilds $(DOMAIN).pot; it is an expensive operation.
134# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
135# The determination of whether the package xyz is a GNU one is based on the
136# heuristic whether some file in the top level directory mentions "GNU xyz".
137# If GNU 'find' is available, we avoid grepping through monster files.
138$(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
139	package_gnu="$(PACKAGE_GNU)"; \
140	test -n "$$package_gnu" || { \
141	  if { if (LC_ALL=C find --version) 2>/dev/null | grep GNU >/dev/null; then \
142	         LC_ALL=C find -L $(top_srcdir) -maxdepth 1 -type f -size -10000000c -exec grep -i 'GNU $(PACKAGE)' /dev/null '{}' ';' 2>/dev/null; \
143	       else \
144	         LC_ALL=C grep -i 'GNU $(PACKAGE)' $(top_srcdir)/* 2>/dev/null; \
145	       fi; \
146	     } | grep -v 'libtool:' >/dev/null; then \
147	     package_gnu=yes; \
148	   else \
149	     package_gnu=no; \
150	   fi; \
151	}; \
152	if test "$$package_gnu" = "yes"; then \
153	  package_prefix='GNU '; \
154	else \
155	  package_prefix=''; \
156	fi; \
157	if test -n '$(MSGID_BUGS_ADDRESS)'; then \
158	  msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
159	else \
160	  msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
161	fi; \
162	case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
163	  '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
164	    $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
165	      --add-comments=TRANSLATORS: \
166	      --copyright-holder='$(COPYRIGHT_HOLDER)' \
167	      --msgid-bugs-address="$$msgid_bugs_address" \
168	      $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
169	      $(POTFILES) \
170	    ;; \
171	  *) \
172	    $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
173	      --add-comments=TRANSLATORS: \
174	      --copyright-holder='$(COPYRIGHT_HOLDER)' \
175	      --package-name="$${package_prefix}$(PACKAGE)" \
176	      --package-version='$(VERSION)' \
177	      --msgid-bugs-address="$$msgid_bugs_address" \
178	      $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
179	      $(POTFILES) \
180	    ;; \
181	esac
182	test ! -f $(DOMAIN).po || { \
183	  if test -f $(srcdir)/$(DOMAIN).pot-header; then \
184	    sed -e '1,/^#$$/d' < $(DOMAIN).po > $(DOMAIN).1po && \
185	    cat $(srcdir)/$(DOMAIN).pot-header $(DOMAIN).1po > $(DOMAIN).po && \
186	    rm -f $(DOMAIN).1po \
187	    || exit 1; \
188	  fi; \
189	  if test -f $(srcdir)/$(DOMAIN).pot; then \
190	    sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
191	    sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
192	    if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
193	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
194	    else \
195	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
196	      mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
197	    fi; \
198	  else \
199	    mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
200	  fi; \
201	}
202
203# This rule has no dependencies: we don't need to update $(DOMAIN).pot at
204# every "make" invocation, only create it when it is missing.
205# Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
206$(srcdir)/$(DOMAIN).pot:
207	$(MAKE) $(DOMAIN).pot-update
208
209# This target rebuilds a PO file if $(DOMAIN).pot has changed.
210# Note that a PO file is not touched if it doesn't need to be changed.
211$(POFILES): $(srcdir)/$(DOMAIN).pot
212	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
213	if test -f "$(srcdir)/$${lang}.po"; then \
214	  test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
215	  echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} --previous $${lang}.po $(DOMAIN).pot"; \
216	  cd $(srcdir) \
217	    && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
218	           '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].*) \
219	             $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \
220	           0.1[6-7] | 0.1[6-7].*) \
221	             $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --previous $${lang}.po $(DOMAIN).pot;; \
222	           *) \
223	             $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} --previous $${lang}.po $(DOMAIN).pot;; \
224	         esac; \
225	       }; \
226	else \
227	  $(MAKE) $${lang}.po-create; \
228	fi
229
230
231install-data-local: install-data-local-@USE_NLS@
232install-data-local-no: all-local
233install-data-local-yes: all-local
234	$(MKDIR_P) $(DESTDIR)$(pkgdatadir)/msgs
235	@catalogs='$(CATALOGS)'; \
236	for cat in $$catalogs; do \
237	  cat=`basename $$cat`; \
238	  if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
239	  $(INSTALL_DATA) $$realcat $(DESTDIR)$(pkgdatadir)/msgs/$$cat; \
240	  echo "installing $$realcat as $(DESTDIR)$(pkgdatadir)/msgs/$$cat"; \
241	done
242
243installdirs-local: installdirs-local-@USE_NLS@
244installdirs-local-no:
245installdirs-local-yes:
246	$(MKDIR_P) $(DESTDIR)$(pkgdatadir)/msgs
247
248uninstall-local: uninstall-local-@USE_NLS@
249uninstall-local-no:
250uninstall-local-yes:
251	catalogs='$(CATALOGS)'; \
252	for cat in $$catalogs; do \
253	  cat=`basename $$cat`; \
254	  rm -f $(DESTDIR)$(pkgdatadir)/msgs/$$cat; \
255	done
256
257html ID:
258
259MOSTLYCLEANFILES =
260MOSTLYCLEANFILES += remove-potcdate.sed
261MOSTLYCLEANFILES += stamp-poT
262MOSTLYCLEANFILES += core core.* *.stackdump $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
263MOSTLYCLEANFILES += *.o
264
265MAINTAINERCLEANFILES = $(DOMAIN).pot stamp-po $(MSGFILES)
266
267EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(MSGFILES)
268
269# Hidden from automake, but really activated. Works around an automake-1.5 bug.
270#distdir: distdir1
271distdir1:
272	$(MAKE) update-po
273	$(MAKE) $(srcdir)/stamp-po
274	@if test -f $(srcdir)/$(DOMAIN).pot; then \
275	  for file in $(DOMAIN).pot stamp-po; do \
276	    if test -f $$file; then d=.; else d=$(srcdir); fi; \
277	    cp -p $$d/$$file $(distdir)/$$file || exit 1; \
278	  done; \
279	else \
280	  case $(XGETTEXT) in \
281	    :) echo "Warning: Creating a tarball without '$(DOMAIN).pot', because a suitable 'xgettext' program was not found in PATH." 1>&2;; \
282	    *) echo "Warning: Creating a tarball without '$(DOMAIN).pot', because 'xgettext' found no strings to extract. Check the POTFILES and the XGETTEXT_OPTIONS in the Makefile.am file." 1>&2;; \
283	  esac; \
284	fi
285
286update-po: Makefile
287	$(MAKE) $(DOMAIN).pot-update
288	test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
289	$(MAKE) update-msg
290
291# General rule for creating PO files.
292
293.nop.po-create:
294	@lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
295	echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
296	exit 1
297
298# General rule for updating PO files.
299
300.nop.po-update:
301	@lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
302	tmpdir=`pwd`; \
303	echo "$$lang:"; \
304	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
305	echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang --previous $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
306	cd $(srcdir); \
307	if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
308	       '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].*) \
309	         $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
310	       0.1[6-7] | 0.1[6-7].*) \
311	         $(MSGMERGE) $(MSGMERGE_OPTIONS) --previous -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
312	       *) \
313	         $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang --previous -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
314	     esac; \
315	   }; then \
316	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
317	    rm -f $$tmpdir/$$lang.new.po; \
318	  else \
319	    if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
320	      :; \
321	    else \
322	      echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
323	      exit 1; \
324	    fi; \
325	  fi; \
326	else \
327	  echo "msgmerge for $$lang.po failed!" 1>&2; \
328	  rm -f $$tmpdir/$$lang.new.po; \
329	fi
330
331$(DUMMYPOFILES):
332
333update-msg: Makefile $(MSGFILES)
334	@:
335# The Makefile rules for $(MSGFILES) are generated by the macro
336# AM_POSTPROCESS_PO_MAKEFILE.
337