1# Example for use of GNU gettext.
2# Copyright (C) 2003-2005 Free Software Foundation, Inc.
3# This file is in the public domain.
4#
5# Makefile configuration - processed by automake.
6
7# List of files which contain translatable strings.
8POTFILES = \
9  hello.ycp
10
11# Usually the message domain is the same as the package name.
12DOMAIN = $(PACKAGE)
13
14# These options get passed to xgettext.
15XGETTEXT_OPTIONS =
16
17# This is the copyright holder that gets inserted into the header of the
18# $(DOMAIN).pot file.  Set this to the copyright holder of the surrounding
19# package.  (Note that the msgstr strings, extracted from the package's
20# sources, belong to the copyright holder of the package.)  Translators are
21# expected to transfer the copyright for their translations to this person
22# or entity, or to disclaim their copyright.  The empty string stands for
23# the public domain; in this case the translators are expected to disclaim
24# their copyright.
25COPYRIGHT_HOLDER = Yoyodyne, Inc.
26
27# This is the email address or URL to which the translators shall report
28# bugs in the untranslated strings:
29# - Strings which are not entire sentences, see the maintainer guidelines
30#   in the GNU gettext documentation, section 'Preparing Strings'.
31# - Strings which use unclear terms or require additional context to be
32#   understood.
33# - Strings which make invalid assumptions about notation of date, time or
34#   money.
35# - Pluralisation problems.
36# - Incorrect English spelling.
37# - Incorrect formatting.
38# It can be your email address, or a mailing list address where translators
39# can write to without being subscribed, or the URL of a web page through
40# which the translators can contact you.
41MSGID_BUGS_ADDRESS = bug-gnu-gettext@gnu.org
42
43# This is the list of locale categories, beyond LC_MESSAGES, for which the
44# message catalogs shall be used.  It is usually empty.
45EXTRA_LOCALE_CATEGORIES =
46
47localedir = @localedir@
48
49MSGMERGE = msgmerge
50MSGMERGE_UPDATE = @MSGMERGE@ --update
51MSGINIT = msginit
52MSGCONV = msgconv
53MSGFILTER = msgfilter
54
55# This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
56POTFILES_DEPS = @POTFILES_DEPS@
57
58# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po)
59POFILES = @POFILES@
60# This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).gmo)
61GMOFILES = @GMOFILES@
62# This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update)
63UPDATEPOFILES = @UPDATEPOFILES@
64# This is computed as $(foreach lang, $(LINGUAS), $(lang).nop)
65DUMMYPOFILES = @DUMMYPOFILES@
66
67# This is computed as
68# $(foreach lang, user-specified subset of $(LINGUAS), $(lang).gmo)
69CATALOGS = @CATALOGS@
70
71SUFFIXES = .po .gmo .mo .sed .sin .nop .po-create .po-update
72
73.po.mo:
74	@echo "$(MSGFMT) -c -o $@ $<"; \
75	$(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
76
77.po.gmo:
78	@lang=`echo $* | sed -e 's,.*/,,'`; \
79	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
80	echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
81	cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
82
83.sin.sed:
84	sed -e '/^#/d' $< > t-$@
85	mv t-$@ $@
86
87
88all-local: all-local-@USE_NLS@
89
90all-local-yes: stamp-po
91all-local-no:
92
93# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
94# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
95# we don't want to bother translators with empty POT files). We assume that
96# LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
97# In this case, stamp-po is a nop (i.e. a phony target).
98
99# stamp-po is a timestamp denoting the last time at which the CATALOGS have
100# been loosely updated. Its purpose is that when a developer or translator
101# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
102# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
103# invocations of "make" will do nothing. This timestamp would not be necessary
104# if updating the $(CATALOGS) would always touch them; however, the rule for
105# $(POFILES) has been designed to not touch files that don't need to be
106# changed.
107stamp-po: $(srcdir)/$(DOMAIN).pot
108	test ! -f $(srcdir)/$(DOMAIN).pot || \
109	  test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
110	@test ! -f $(srcdir)/$(DOMAIN).pot || { \
111	  echo "touch stamp-po" && \
112	  echo timestamp > stamp-poT && \
113	  mv stamp-poT stamp-po; \
114	}
115
116# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
117# otherwise packages like GCC can not be built if only parts of the source
118# have been downloaded.
119
120# This target rebuilds $(DOMAIN).pot; it is an expensive operation.
121# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
122$(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
123	if test -n '$(MSGID_BUGS_ADDRESS)'; then \
124	  msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
125	else \
126	  msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
127	fi; \
128	$(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
129	  --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
130	  --copyright-holder='$(COPYRIGHT_HOLDER)' \
131	  --msgid-bugs-address="$$msgid_bugs_address" \
132	  $(POTFILES)
133	test ! -f $(DOMAIN).po || { \
134	  if test -f $(srcdir)/$(DOMAIN).pot; then \
135	    sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
136	    sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
137	    if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
138	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
139	    else \
140	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
141	      mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
142	    fi; \
143	  else \
144	    mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
145	  fi; \
146	}
147
148# This rule has no dependencies: we don't need to update $(DOMAIN).pot at
149# every "make" invocation, only create it when it is missing.
150# Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
151$(srcdir)/$(DOMAIN).pot:
152	$(MAKE) $(DOMAIN).pot-update
153
154# This target rebuilds a PO file if $(DOMAIN).pot has changed.
155# Note that a PO file is not touched if it doesn't need to be changed.
156$(POFILES): $(srcdir)/$(DOMAIN).pot
157	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
158	if test -f "$(srcdir)/$${lang}.po"; then \
159	  test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
160	  echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
161	  cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
162	else \
163	  $(MAKE) $${lang}.po-create; \
164	fi
165
166
167install-data-local: install-data-local-@USE_NLS@
168install-data-local-no: all-local
169install-data-local-yes: all-local
170	$(mkinstalldirs) $(DESTDIR)$(datadir)
171	@catalogs='$(CATALOGS)'; \
172	for cat in $$catalogs; do \
173	  cat=`basename $$cat`; \
174	  lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
175	  dir=$(localedir)/$$lang/LC_MESSAGES; \
176	  $(mkinstalldirs) $(DESTDIR)$$dir; \
177	  if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
178	  $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
179	  echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
180	  for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
181	    if test -n "$$lc"; then \
182	      if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
183	        link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
184	        mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
185	        mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
186	        (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
187	         for file in *; do \
188	           if test -f $$file; then \
189	             ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
190	           fi; \
191	         done); \
192	        rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
193	      else \
194	        if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
195	          :; \
196	        else \
197	          rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
198	          mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
199	        fi; \
200	      fi; \
201	      rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
202	      ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
203	      ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
204	      cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
205	      echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
206	    fi; \
207	  done; \
208	done
209
210installdirs-local: installdirs-local-@USE_NLS@
211installdirs-local-no:
212installdirs-local-yes:
213	$(mkinstalldirs) $(DESTDIR)$(datadir)
214	@catalogs='$(CATALOGS)'; \
215	for cat in $$catalogs; do \
216	  cat=`basename $$cat`; \
217	  lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
218	  dir=$(localedir)/$$lang/LC_MESSAGES; \
219	  $(mkinstalldirs) $(DESTDIR)$$dir; \
220	  for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
221	    if test -n "$$lc"; then \
222	      if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
223	        link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
224	        mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
225	        mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
226	        (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
227	         for file in *; do \
228	           if test -f $$file; then \
229	             ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
230	           fi; \
231	         done); \
232	        rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
233	      else \
234	        if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
235	          :; \
236	        else \
237	          rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
238	          mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
239	        fi; \
240	      fi; \
241	    fi; \
242	  done; \
243	done
244
245uninstall-local: uninstall-local-@USE_NLS@
246uninstall-local-no:
247uninstall-local-yes:
248	catalogs='$(CATALOGS)'; \
249	for cat in $$catalogs; do \
250	  cat=`basename $$cat`; \
251	  lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
252	  for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
253	    rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
254	  done; \
255	done
256
257html ID:
258
259MOSTLYCLEANFILES =
260MOSTLYCLEANFILES += remove-potcdate.sed
261MOSTLYCLEANFILES += stamp-poT
262MOSTLYCLEANFILES += core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
263MOSTLYCLEANFILES += *.o
264
265DISTCLEANFILES = *.mo
266
267MAINTAINERCLEANFILES = stamp-po $(GMOFILES)
268
269EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(GMOFILES)
270
271# Hidden from automake, but really activated. Works around an automake-1.5 bug.
272#distdir: distdir1
273distdir1:
274	$(MAKE) update-po
275	if test -f $(srcdir)/$(DOMAIN).pot; then \
276	  for file in $(DOMAIN).pot stamp-po; do \
277	    if test -f $$file; then d=.; else d=$(srcdir); fi; \
278	    cp -p $$d/$$file $(distdir)/$$file || exit 1; \
279	  done; \
280	fi
281
282update-po: Makefile
283	$(MAKE) $(DOMAIN).pot-update
284	test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
285	$(MAKE) update-gmo
286
287# General rule for creating PO files.
288
289.nop.po-create:
290	@lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
291	echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
292	exit 1
293
294# General rule for updating PO files.
295
296.nop.po-update:
297	@lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
298	tmpdir=`pwd`; \
299	echo "$$lang:"; \
300	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
301	echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
302	cd $(srcdir); \
303	if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
304	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
305	    rm -f $$tmpdir/$$lang.new.po; \
306	  else \
307	    if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
308	      :; \
309	    else \
310	      echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
311	      exit 1; \
312	    fi; \
313	  fi; \
314	else \
315	  echo "msgmerge for $$lang.po failed!" 1>&2; \
316	  rm -f $$tmpdir/$$lang.new.po; \
317	fi
318
319$(DUMMYPOFILES):
320
321update-gmo: Makefile $(GMOFILES)
322	@:
323