1# Makefile for PO directory in any package using GNU gettext.
2# Copyright (C) 1995-1997, 2000-2002 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
11PACKAGE = diffutils
12VERSION = 2.8.1
13
14SHELL = /bin/sh
15
16
17srcdir = .
18top_srcdir = ..
19
20
21prefix = /usr/local
22exec_prefix = ${prefix}
23datadir = ${prefix}/share
24localedir = $(datadir)/locale
25gettextsrcdir = $(datadir)/gettext/po
26
27INSTALL = /bin/install -c
28INSTALL_DATA = ${INSTALL} -m 644
29MKINSTALLDIRS = config/mkinstalldirs
30mkinstalldirs = $(SHELL) `case "$(MKINSTALLDIRS)" in /*) echo "$(MKINSTALLDIRS)" ;; *) echo "$(top_builddir)/$(MKINSTALLDIRS)" ;; esac`
31
32GMSGFMT = :
33MSGFMT = :
34XGETTEXT = AWK='gawk' $(SHELL) $(top_srcdir)/exgettext :
35MSGMERGE = msgmerge
36MSGMERGE_UPDATE = : --update
37MSGINIT = msginit
38MSGCONV = msgconv
39MSGFILTER = msgfilter
40
41POFILES =  cs.po da.po de.po en_GB.po eo.po es.po fr.po gl.po he.po id.po ja.po pl.po ru.po sv.po tr.po zh_TW.po
42GMOFILES =  cs.gmo da.gmo de.gmo en_GB.gmo eo.gmo es.gmo fr.gmo gl.gmo he.gmo id.gmo ja.gmo pl.gmo ru.gmo sv.gmo tr.gmo zh_TW.gmo
43UPDATEPOFILES =  cs.po-update da.po-update de.po-update en_GB.po-update eo.po-update es.po-update fr.po-update gl.po-update he.po-update id.po-update ja.po-update pl.po-update ru.po-update sv.po-update tr.po-update zh_TW.po-update
44DUMMYPOFILES =  cs.nop da.nop de.nop en_GB.nop eo.nop es.nop fr.nop gl.nop he.nop id.nop ja.nop pl.nop ru.nop sv.nop tr.nop zh_TW.nop
45DISTFILES.common = Makefile.in.in Makevars remove-potcdate.sin \
46$(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
47DISTFILES = $(DISTFILES.common) POTFILES.in $(DOMAIN).pot \
48$(POFILES) $(GMOFILES) \
49$(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
50
51POTFILES = \
52     ../lib/c-stack.c \
53     ../lib/error.c \
54     ../lib/freesoft.c \
55     ../lib/getopt.c \
56     ../lib/regex.c \
57     ../lib/xmalloc.c \
58     ../src/analyze.c \
59     ../src/cmp.c \
60     ../src/diff.c \
61     ../src/diff3.c \
62     ../src/dir.c \
63     ../src/sdiff.c \
64     ../src/util.c
65
66CATALOGS =  cs.gmo da.gmo de.gmo en_GB.gmo eo.gmo es.gmo fr.gmo gl.gmo he.gmo id.gmo ja.gmo pl.gmo ru.gmo sv.gmo tr.gmo zh_TW.gmo
67
68# Makevars gets inserted here. (Don't remove this line!)
69# Makefile variables for PO directory in any package using GNU gettext.
70
71# Usually the message domain is the same as the package name.
72DOMAIN = $(PACKAGE)
73
74# These two variables depend on the location of this directory.
75subdir = po
76top_builddir = ..
77
78# These options get passed to xgettext.
79XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
80
81# This is the copyright holder that gets inserted into the header of the
82# $(DOMAIN).pot file.  Set this to the copyright holder of the surrounding
83# package.  (Note that the msgstr strings, extracted from the package's
84# sources, belong to the copyright holder of the package.)  Translators are
85# expected to transfer the copyright for their translations to this person
86# or entity, or to disclaim their copyright.  The empty string stands for
87# the public domain; in this case the translators are expected to disclaim
88# their copyright.
89COPYRIGHT_HOLDER = Free Software Foundation, Inc.
90
91# This is the list of locale categories, beyond LC_MESSAGES, for which the
92# message catalogs shall be used.  It is usually empty.
93EXTRA_LOCALE_CATEGORIES =
94
95.SUFFIXES:
96.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-update
97
98.po.mo:
99	@echo "$(MSGFMT) -c -o $@ $<"; \
100	$(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
101
102.po.gmo:
103	@lang=`echo $* | sed -e 's,.*/,,'`; \
104	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
105	echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
106	cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
107
108.sin.sed:
109	sed -e '/^#/d' $< > t-$@
110	mv t-$@ $@
111
112
113all: all-no
114
115all-yes: $(CATALOGS)
116all-no:
117
118# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
119# otherwise packages like GCC can not be built if only parts of the source
120# have been downloaded.
121
122$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
123	$(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
124	  --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
125	  --files-from=$(srcdir)/POTFILES.in \
126	  --copyright-holder='$(COPYRIGHT_HOLDER)'
127	test ! -f $(DOMAIN).po || { \
128	  if test -f $(srcdir)/$(DOMAIN).pot; then \
129	    sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
130	    sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
131	    if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
132	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
133	    else \
134	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
135	      mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
136	    fi; \
137	  else \
138	    mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
139	  fi; \
140	}
141
142$(srcdir)/$(DOMAIN).pot:
143	$(MAKE) $(DOMAIN).pot-update
144
145$(POFILES): $(srcdir)/$(DOMAIN).pot
146	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
147	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
148	echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
149	cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot
150
151
152install: install-exec install-data
153install-exec:
154install-data: install-data-no
155	if test "$(PACKAGE)" = "gettext"; then \
156	  $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
157	  for file in $(DISTFILES.common); do \
158	    $(INSTALL_DATA) $(srcdir)/$$file \
159			    $(DESTDIR)$(gettextsrcdir)/$$file; \
160	  done; \
161	else \
162	  : ; \
163	fi
164install-data-no: all
165install-data-yes: all
166	$(mkinstalldirs) $(DESTDIR)$(datadir)
167	@catalogs='$(CATALOGS)'; \
168	for cat in $$catalogs; do \
169	  cat=`basename $$cat`; \
170	  lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
171	  dir=$(localedir)/$$lang/LC_MESSAGES; \
172	  $(mkinstalldirs) $(DESTDIR)$$dir; \
173	  if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
174	  $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
175	  echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
176	  for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
177	    if test -n "$$lc"; then \
178	      if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
179	        link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
180	        mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
181	        mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
182	        (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
183	         for file in *; do \
184	           if test -f $$file; then \
185	             ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
186	           fi; \
187	         done); \
188	        rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
189	      else \
190	        if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
191	          :; \
192	        else \
193	          rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
194	          mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
195	        fi; \
196	      fi; \
197	      rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
198	      ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
199	      ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
200	      cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
201	      echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
202	    fi; \
203	  done; \
204	done
205
206install-strip: install
207
208installdirs: installdirs-exec installdirs-data
209installdirs-exec:
210installdirs-data: installdirs-data-no
211	if test "$(PACKAGE)" = "gettext"; then \
212	  $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
213	else \
214	  : ; \
215	fi
216installdirs-data-no:
217installdirs-data-yes:
218	$(mkinstalldirs) $(DESTDIR)$(datadir)
219	@catalogs='$(CATALOGS)'; \
220	for cat in $$catalogs; do \
221	  cat=`basename $$cat`; \
222	  lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
223	  dir=$(localedir)/$$lang/LC_MESSAGES; \
224	  $(mkinstalldirs) $(DESTDIR)$$dir; \
225	  for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
226	    if test -n "$$lc"; then \
227	      if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
228	        link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
229	        mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
230	        mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
231	        (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
232	         for file in *; do \
233	           if test -f $$file; then \
234	             ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
235	           fi; \
236	         done); \
237	        rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
238	      else \
239	        if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
240	          :; \
241	        else \
242	          rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
243	          mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
244	        fi; \
245	      fi; \
246	    fi; \
247	  done; \
248	done
249
250# Define this as empty until I found a useful application.
251installcheck:
252
253uninstall: uninstall-exec uninstall-data
254uninstall-exec:
255uninstall-data: uninstall-data-no
256	if test "$(PACKAGE)" = "gettext"; then \
257	  for file in $(DISTFILES.common); do \
258	    rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
259	  done; \
260	else \
261	  : ; \
262	fi
263uninstall-data-no:
264uninstall-data-yes:
265	catalogs='$(CATALOGS)'; \
266	for cat in $$catalogs; do \
267	  cat=`basename $$cat`; \
268	  lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
269	  for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
270	    rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
271	  done; \
272	done
273
274check: all
275
276dvi info tags TAGS ID:
277
278mostlyclean:
279	rm -f remove-potcdate.sed
280	rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
281	rm -fr *.o
282
283clean: mostlyclean
284
285distclean: clean
286	rm -f Makefile Makefile.in POTFILES *.mo
287
288maintainer-clean: distclean
289	@echo "This command is intended for maintainers to use;"
290	@echo "it deletes files that may require special tools to rebuild."
291	rm -f $(GMOFILES)
292
293distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
294dist distdir:
295	$(MAKE) update-po
296	@$(MAKE) dist2
297# This is a separate target because 'update-po' must be executed before.
298dist2: $(DISTFILES)
299	dists="$(DISTFILES)"; \
300	if test -f $(srcdir)/ChangeLog; then dists="$$dists ChangeLog"; fi; \
301	if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
302	for file in $$dists; do \
303	  if test -f $$file; then \
304	    cp -p $$file $(distdir); \
305	  else \
306	    cp -p $(srcdir)/$$file $(distdir); \
307	  fi; \
308	done
309
310update-po: Makefile
311	$(MAKE) $(DOMAIN).pot-update
312	$(MAKE) $(UPDATEPOFILES)
313	$(MAKE) update-gmo
314
315# General rule for updating PO files.
316
317.nop.po-update:
318	@lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
319	if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; fi; \
320	tmpdir=`pwd`; \
321	echo "$$lang:"; \
322	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
323	echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
324	cd $(srcdir); \
325	if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
326	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
327	    rm -f $$tmpdir/$$lang.new.po; \
328	  else \
329	    if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
330	      :; \
331	    else \
332	      echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
333	      exit 1; \
334	    fi; \
335	  fi; \
336	else \
337	  echo "msgmerge for $$lang.po failed!" 1>&2; \
338	  rm -f $$tmpdir/$$lang.new.po; \
339	fi
340
341$(DUMMYPOFILES):
342
343update-gmo: Makefile $(GMOFILES)
344	@:
345
346Makefile: Makefile.in.in $(top_builddir)/config.status POTFILES.in
347	cd $(top_builddir) \
348	  && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
349	       $(SHELL) ./config.status
350
351force:
352
353# Tell versions [3.59,3.63) of GNU make not to export all variables.
354# Otherwise a system limit (for SysV at least) may be exceeded.
355.NOEXPORT:
356# Special Makefile rules for English message catalogs with quotation marks.
357
358DISTFILES.common.extra1 = quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot
359
360.SUFFIXES: .insert-header .po-update-en
361
362en@quot.po-update: en@quot.po-update-en
363en@boldquot.po-update: en@boldquot.po-update-en
364
365.insert-header.po-update-en:
366	@lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \
367	if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \
368	tmpdir=`pwd`; \
369	echo "$$lang:"; \
370	ll=`echo $$lang | sed -e 's/@.*//'`; \
371	LC_ALL=C; export LC_ALL; \
372	cd $(srcdir); \
373	if $(MSGINIT) -i $(DOMAIN).pot --no-translator -l $$ll -o - 2>/dev/null | sed -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | $(MSGFILTER) sed -f `echo $$lang | sed -e 's/.*@//'`.sed 2>/dev/null > $$tmpdir/$$lang.new.po; then \
374	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
375	    rm -f $$tmpdir/$$lang.new.po; \
376	  else \
377	    if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
378	      :; \
379	    else \
380	      echo "creation of $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
381	      exit 1; \
382	    fi; \
383	  fi; \
384	else \
385	  echo "creation of $$lang.po failed!" 1>&2; \
386	  rm -f $$tmpdir/$$lang.new.po; \
387	fi
388
389en@quot.insert-header: insert-header.sin
390	sed -e '/^#/d' -e 's/HEADER/en@quot.header/g' $(srcdir)/insert-header.sin > en@quot.insert-header
391
392en@boldquot.insert-header: insert-header.sin
393	sed -e '/^#/d' -e 's/HEADER/en@boldquot.header/g' $(srcdir)/insert-header.sin > en@boldquot.insert-header
394
395mostlyclean: mostlyclean-quot
396mostlyclean-quot:
397	rm -f *.insert-header
398