• 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.cs
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 =
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
61pkglibdir = $(libdir)/$(PACKAGE)
62
63MSGMERGE = @MSGMERGE@
64MSGMERGE_UPDATE = @MSGMERGE@ --update
65MSGMERGE_FOR_MSGFMT_OPTION = @MSGMERGE_FOR_MSGFMT_OPTION@
66MSGINIT = msginit
67MSGCONV = msgconv
68MSGFILTER = msgfilter
69
70# This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
71POTFILES_DEPS = @POTFILES_DEPS@
72
73# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po)
74POFILES = @POFILES@
75# This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update)
76UPDATEPOFILES = @UPDATEPOFILES@
77# This is computed as $(foreach lang, $(LINGUAS), $(lang).nop)
78DUMMYPOFILES = @DUMMYPOFILES@
79# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(frob $(lang))/$(DOMAIN).resources.dll)
80RESOURCESDLLFILES = @RESOURCESDLLFILES@
81
82# This is computed as
83# $(foreach lang, user-specified subset of $(LINGUAS), $(frob $(lang))/$(DOMAIN).resources.dll)
84CATALOGS = @CSHARPCATALOGS@
85
86SUFFIXES = .sed .sin .nop .po-create .po-update
87
88# The .pot file, stamp-po, .po files, and .resources.dll files appear in release
89# tarballs.
90# The GNU Coding Standards say in
91# <https://www.gnu.org/prep/standards/html_node/Makefile-Basics.html>:
92#   "GNU distributions usually contain some files which are not source files
93#    ... . Since these files normally appear in the source directory, they
94#    should always appear in the source directory, not in the build directory.
95#    So Makefile rules to update them should put the updated files in the
96#    source directory."
97# Therefore we put these files in the source directory, not the build directory.
98
99.sin.sed:
100	sed -e '/^#/d' $< > t-$@
101	mv t-$@ $@
102
103
104all-local: all-local-@USE_NLS@
105
106all-local-yes: $(srcdir)/stamp-po
107all-local-no:
108
109# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
110# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
111# we don't want to bother translators with empty POT files). We assume that
112# LINGUAS is empty in this case, i.e. $(POFILES) and $(RESOURCESDLLFILES) are
113# empty. In this case, $(srcdir)/stamp-po is a nop (i.e. a phony target).
114
115# $(srcdir)/stamp-po is a timestamp denoting the last time at which the CATALOGS
116# have been loosely updated. Its purpose is that when a developer or translator
117# checks out the package from a version control system, and the $(DOMAIN).pot
118# file is not under version control, "make" will update the $(DOMAIN).pot and
119# the $(CATALOGS), but subsequent invocations of "make" will do nothing. This
120# timestamp would not be necessary if updating the $(CATALOGS) would always
121# touch them; however, the rule for $(POFILES) has been designed to not touch
122# files that don't need to be changed.
123$(srcdir)/stamp-po: $(srcdir)/$(DOMAIN).pot
124	test ! -f $(srcdir)/$(DOMAIN).pot || \
125	  test -z "$(RESOURCESDLLFILES)" || $(MAKE) $(RESOURCESDLLFILES)
126	@test ! -f $(srcdir)/$(DOMAIN).pot || { \
127	  echo "touch $(srcdir)/stamp-po" && \
128	  echo timestamp > $(srcdir)/stamp-poT && \
129	  mv $(srcdir)/stamp-poT $(srcdir)/stamp-po; \
130	}
131
132# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
133# otherwise packages like GCC can not be built if only parts of the source
134# have been downloaded.
135
136# This target rebuilds $(DOMAIN).pot; it is an expensive operation.
137# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
138# The determination of whether the package xyz is a GNU one is based on the
139# heuristic whether some file in the top level directory mentions "GNU xyz".
140# If GNU 'find' is available, we avoid grepping through monster files.
141$(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
142	package_gnu="$(PACKAGE_GNU)"; \
143	test -n "$$package_gnu" || { \
144	  if { if (LC_ALL=C find --version) 2>/dev/null | grep GNU >/dev/null; then \
145	         LC_ALL=C find -L $(top_srcdir) -maxdepth 1 -type f -size -10000000c -exec grep -i 'GNU $(PACKAGE)' /dev/null '{}' ';' 2>/dev/null; \
146	       else \
147	         LC_ALL=C grep -i 'GNU $(PACKAGE)' $(top_srcdir)/* 2>/dev/null; \
148	       fi; \
149	     } | grep -v 'libtool:' >/dev/null; then \
150	     package_gnu=yes; \
151	   else \
152	     package_gnu=no; \
153	   fi; \
154	}; \
155	if test "$$package_gnu" = "yes"; then \
156	  package_prefix='GNU '; \
157	else \
158	  package_prefix=''; \
159	fi; \
160	if test -n '$(MSGID_BUGS_ADDRESS)'; then \
161	  msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
162	else \
163	  msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
164	fi; \
165	case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
166	  '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
167	    $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
168	      --add-comments=TRANSLATORS: \
169	      --copyright-holder='$(COPYRIGHT_HOLDER)' \
170	      --msgid-bugs-address="$$msgid_bugs_address" \
171	      $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
172	      $(POTFILES) \
173	    ;; \
174	  *) \
175	    $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
176	      --add-comments=TRANSLATORS: \
177	      --copyright-holder='$(COPYRIGHT_HOLDER)' \
178	      --package-name="$${package_prefix}$(PACKAGE)" \
179	      --package-version='$(VERSION)' \
180	      --msgid-bugs-address="$$msgid_bugs_address" \
181	      $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
182	      $(POTFILES) \
183	    ;; \
184	esac
185	test ! -f $(DOMAIN).po || { \
186	  if test -f $(srcdir)/$(DOMAIN).pot-header; then \
187	    sed -e '1,/^#$$/d' < $(DOMAIN).po > $(DOMAIN).1po && \
188	    cat $(srcdir)/$(DOMAIN).pot-header $(DOMAIN).1po > $(DOMAIN).po && \
189	    rm -f $(DOMAIN).1po \
190	    || exit 1; \
191	  fi; \
192	  if test -f $(srcdir)/$(DOMAIN).pot; then \
193	    sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
194	    sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
195	    if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
196	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
197	    else \
198	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
199	      mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
200	    fi; \
201	  else \
202	    mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
203	  fi; \
204	}
205
206# This rule has no dependencies: we don't need to update $(DOMAIN).pot at
207# every "make" invocation, only create it when it is missing.
208# Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
209$(srcdir)/$(DOMAIN).pot:
210	$(MAKE) $(DOMAIN).pot-update
211
212# This target rebuilds a PO file if $(DOMAIN).pot has changed.
213# Note that a PO file is not touched if it doesn't need to be changed.
214$(POFILES): $(srcdir)/$(DOMAIN).pot
215	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
216	if test -f "$(srcdir)/$${lang}.po"; then \
217	  test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
218	  echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} --previous $${lang}.po $(DOMAIN).pot"; \
219	  cd $(srcdir) \
220	    && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
221	           '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].*) \
222	             $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \
223	           0.1[6-7] | 0.1[6-7].*) \
224	             $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --previous $${lang}.po $(DOMAIN).pot;; \
225	           *) \
226	             $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} --previous $${lang}.po $(DOMAIN).pot;; \
227	         esac; \
228	       }; \
229	else \
230	  $(MAKE) $${lang}.po-create; \
231	fi
232
233
234install-data-local: install-data-local-@USE_NLS@
235install-data-local-no: all-local
236install-data-local-yes: all-local
237	$(MKDIR_P) $(DESTDIR)$(pkglibdir)
238	@catalogs='$(CATALOGS)'; \
239	for cat in $$catalogs; do \
240	  $(MKDIR_P) $(DESTDIR)$(pkglibdir)/`echo $$cat | sed -e 's,/[^/]*$$,,'`; \
241	  if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
242	  $(INSTALL_DATA) $$realcat $(DESTDIR)$(pkglibdir)/$$cat; \
243	  echo "installing $$realcat as $(DESTDIR)$(pkglibdir)/$$cat"; \
244	done
245
246installdirs-local: installdirs-local-@USE_NLS@
247installdirs-local-no:
248installdirs-local-yes:
249	$(MKDIR_P) $(DESTDIR)$(pkglibdir)
250	@catalogs='$(CATALOGS)'; \
251	for cat in $$catalogs; do \
252	  $(MKDIR_P) $(DESTDIR)$(pkglibdir)/`echo $$cat | sed -e 's,/[^/]*$$,,'`; \
253	done
254
255uninstall-local: uninstall-local-@USE_NLS@
256uninstall-local-no:
257uninstall-local-yes:
258	catalogs='$(CATALOGS)'; \
259	for cat in $$catalogs; do \
260	  rm -f $(DESTDIR)$(pkglibdir)/$$cat; \
261	done
262
263html ID:
264
265MOSTLYCLEANFILES =
266MOSTLYCLEANFILES += remove-potcdate.sed
267MOSTLYCLEANFILES += stamp-poT
268MOSTLYCLEANFILES += core core.* *.stackdump $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
269
270MAINTAINERCLEANFILES = $(DOMAIN).pot stamp-po
271maintainer-clean-local:
272	if test -n "$(RESOURCESDLLFILES)"; then \
273	  for file in $(RESOURCESDLLFILES); do \
274	    rm -f "$$file"; \
275	    dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
276	    if test -d "$$dir"; then rmdir "$$dir"; fi; \
277	  done; \
278	fi
279
280EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(RESOURCESDLLFILES)
281
282# Hidden from automake, but really activated. Works around an automake-1.5 bug.
283#distdir: distdir1
284distdir1:
285	$(MAKE) update-po
286	$(MAKE) $(srcdir)/stamp-po
287	@if test -f $(srcdir)/$(DOMAIN).pot; then \
288	  for file in $(DOMAIN).pot stamp-po; do \
289	    if test -f $$file; then d=.; else d=$(srcdir); fi; \
290	    cp -p $$d/$$file $(distdir)/$$file || exit 1; \
291	  done; \
292	else \
293	  case $(XGETTEXT) in \
294	    :) echo "Warning: Creating a tarball without '$(DOMAIN).pot', because a suitable 'xgettext' program was not found in PATH." 1>&2;; \
295	    *) 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;; \
296	  esac; \
297	fi
298
299update-po: Makefile
300	$(MAKE) $(DOMAIN).pot-update
301	test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
302	$(MAKE) update-resourcesdll
303
304# General rule for creating PO files.
305
306.nop.po-create:
307	@lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
308	echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
309	exit 1
310
311# General rule for updating PO files.
312
313.nop.po-update:
314	@lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
315	tmpdir=`pwd`; \
316	echo "$$lang:"; \
317	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
318	echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang --previous $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
319	cd $(srcdir); \
320	if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
321	       '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].*) \
322	         $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
323	       0.1[6-7] | 0.1[6-7].*) \
324	         $(MSGMERGE) $(MSGMERGE_OPTIONS) --previous -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
325	       *) \
326	         $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang --previous -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
327	     esac; \
328	   }; then \
329	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
330	    rm -f $$tmpdir/$$lang.new.po; \
331	  else \
332	    if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
333	      :; \
334	    else \
335	      echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
336	      exit 1; \
337	    fi; \
338	  fi; \
339	else \
340	  echo "msgmerge for $$lang.po failed!" 1>&2; \
341	  rm -f $$tmpdir/$$lang.new.po; \
342	fi
343
344$(DUMMYPOFILES):
345
346update-resourcesdll: Makefile $(RESOURCESDLLFILES)
347	@:
348# The Makefile rules for $(RESOURCESDLLFILES) are generated by the macro
349# AM_POSTPROCESS_PO_MAKEFILE.
350