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 = @PACKAGE@
12VERSION = @VERSION@
13
14SHELL = /bin/sh
15@SET_MAKE@
16
17srcdir = @srcdir@
18top_srcdir = @top_srcdir@
19VPATH = @srcdir@
20
21prefix = @prefix@
22exec_prefix = @exec_prefix@
23datadir = @datadir@
24localedir = $(datadir)/locale
25gettextsrcdir = $(datadir)/gettext/po
26
27INSTALL = @INSTALL@
28INSTALL_DATA = @INSTALL_DATA@
29MKINSTALLDIRS = @MKINSTALLDIRS@
30#mkinstalldirs = $(SHELL) `case "$(MKINSTALLDIRS)" in /*) echo "$(MKINSTALLDIRS)" ;; *) echo "$(top_builddir)/$(MKINSTALLDIRS)" ;; esac`
31mkinstalldirs = @MKINSTALLDIRS@
32
33GMSGFMT = @GMSGFMT@
34MSGFMT = @MSGFMT@
35XGETTEXT = @XGETTEXT@
36MSGMERGE = msgmerge
37MSGMERGE_UPDATE = @MSGMERGE@ --update
38MSGINIT = msginit
39MSGCONV = msgconv
40MSGFILTER = msgfilter
41
42POFILES = @POFILES@
43GMOFILES = @GMOFILES@
44UPDATEPOFILES = @UPDATEPOFILES@
45DUMMYPOFILES = @DUMMYPOFILES@
46DISTFILES.common = Makefile.in.in Makevars remove-potcdate.sin \
47$(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
48DISTFILES = $(DISTFILES.common) POTFILES.in $(DOMAIN).pot \
49$(POFILES) $(GMOFILES) \
50$(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
51
52POTFILES = \
53
54CATALOGS = @CATALOGS@
55
56# Makevars gets inserted here. (Don't remove this line!)
57
58.SUFFIXES:
59.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-update
60
61.po.mo:
62	@echo "$(MSGFMT) -c -o $@ $<"; \
63	$(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
64
65.po.gmo:
66	@lang=`echo $* | sed -e 's,.*/,,'`; \
67	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
68	echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
69	cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
70
71.sin.sed:
72	sed -e '/^#/d' $< > t-$@
73	mv t-$@ $@
74
75
76all: all-@USE_NLS@
77
78all-yes: $(CATALOGS)
79all-no:
80
81# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
82# otherwise packages like GCC can not be built if only parts of the source
83# have been downloaded.
84
85$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
86	$(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
87	  --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
88	  --files-from=$(srcdir)/POTFILES.in \
89	  --copyright-holder='$(COPYRIGHT_HOLDER)'
90	test ! -f $(DOMAIN).po || { \
91	  if test -f $(srcdir)/$(DOMAIN).pot; then \
92	    sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
93	    sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
94	    if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
95	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
96	    else \
97	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
98	      mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
99	    fi; \
100	  else \
101	    mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
102	  fi; \
103	}
104
105$(srcdir)/$(DOMAIN).pot:
106	$(MAKE) $(DOMAIN).pot-update
107
108$(POFILES): $(srcdir)/$(DOMAIN).pot
109	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
110	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
111	echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
112	cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot
113
114
115install: install-exec install-data
116install-exec:
117install-data: install-data-@USE_NLS@
118	if test "$(PACKAGE)" = "gettext"; then \
119	  $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
120	  for file in $(DISTFILES.common); do \
121	    $(INSTALL_DATA) $(srcdir)/$$file \
122			    $(DESTDIR)$(gettextsrcdir)/$$file; \
123	  done; \
124	else \
125	  : ; \
126	fi
127install-data-no: all
128install-data-yes: all
129	$(mkinstalldirs) $(DESTDIR)$(datadir)
130	@catalogs='$(CATALOGS)'; \
131	for cat in $$catalogs; do \
132	  cat=`basename $$cat`; \
133	  lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
134	  dir=$(localedir)/$$lang/LC_MESSAGES; \
135	  $(mkinstalldirs) $(DESTDIR)$$dir; \
136	  if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
137	  $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
138	  echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
139	  for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
140	    if test -n "$$lc"; then \
141	      if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
142	        link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
143	        mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
144	        mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
145	        (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
146	         for file in *; do \
147	           if test -f $$file; then \
148	             ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
149	           fi; \
150	         done); \
151	        rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
152	      else \
153	        if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
154	          :; \
155	        else \
156	          rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
157	          mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
158	        fi; \
159	      fi; \
160	      rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
161	      ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
162	      ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
163	      cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
164	      echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
165	    fi; \
166	  done; \
167	done
168
169install-strip: install
170
171installdirs: installdirs-exec installdirs-data
172installdirs-exec:
173installdirs-data: installdirs-data-@USE_NLS@
174	if test "$(PACKAGE)" = "gettext"; then \
175	  $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
176	else \
177	  : ; \
178	fi
179installdirs-data-no:
180installdirs-data-yes:
181	$(mkinstalldirs) $(DESTDIR)$(datadir)
182	@catalogs='$(CATALOGS)'; \
183	for cat in $$catalogs; do \
184	  cat=`basename $$cat`; \
185	  lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
186	  dir=$(localedir)/$$lang/LC_MESSAGES; \
187	  $(mkinstalldirs) $(DESTDIR)$$dir; \
188	  for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
189	    if test -n "$$lc"; then \
190	      if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
191	        link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
192	        mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
193	        mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
194	        (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
195	         for file in *; do \
196	           if test -f $$file; then \
197	             ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
198	           fi; \
199	         done); \
200	        rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
201	      else \
202	        if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
203	          :; \
204	        else \
205	          rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
206	          mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
207	        fi; \
208	      fi; \
209	    fi; \
210	  done; \
211	done
212
213# Define this as empty until I found a useful application.
214installcheck:
215
216uninstall: uninstall-exec uninstall-data
217uninstall-exec:
218uninstall-data: uninstall-data-@USE_NLS@
219	if test "$(PACKAGE)" = "gettext"; then \
220	  for file in $(DISTFILES.common); do \
221	    rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
222	  done; \
223	else \
224	  : ; \
225	fi
226uninstall-data-no:
227uninstall-data-yes:
228	catalogs='$(CATALOGS)'; \
229	for cat in $$catalogs; do \
230	  cat=`basename $$cat`; \
231	  lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
232	  for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
233	    rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
234	  done; \
235	done
236
237check: all
238
239dvi info tags TAGS ID:
240
241mostlyclean:
242	rm -f remove-potcdate.sed
243	rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
244	rm -fr *.o
245
246clean: mostlyclean
247
248distclean: clean
249	rm -f Makefile Makefile.in POTFILES *.mo
250
251maintainer-clean: distclean
252	@echo "This command is intended for maintainers to use;"
253	@echo "it deletes files that may require special tools to rebuild."
254	rm -f $(GMOFILES)
255
256distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
257dist distdir:
258	$(MAKE) update-po
259	@$(MAKE) dist2
260# This is a separate target because 'update-po' must be executed before.
261dist2: $(DISTFILES)
262	dists="$(DISTFILES)"; \
263	if test -f $(srcdir)/ChangeLog; then dists="$$dists ChangeLog"; fi; \
264	if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
265	for file in $$dists; do \
266	  if test -f $$file; then \
267	    cp -p $$file $(distdir); \
268	  else \
269	    cp -p $(srcdir)/$$file $(distdir); \
270	  fi; \
271	done
272
273update-po: Makefile
274	$(MAKE) $(DOMAIN).pot-update
275	$(MAKE) $(UPDATEPOFILES)
276	$(MAKE) update-gmo
277
278# General rule for updating PO files.
279
280.nop.po-update:
281	@lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
282	if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; fi; \
283	tmpdir=`pwd`; \
284	echo "$$lang:"; \
285	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
286	echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
287	cd $(srcdir); \
288	if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
289	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
290	    rm -f $$tmpdir/$$lang.new.po; \
291	  else \
292	    if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
293	      :; \
294	    else \
295	      echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
296	      exit 1; \
297	    fi; \
298	  fi; \
299	else \
300	  echo "msgmerge for $$lang.po failed!" 1>&2; \
301	  rm -f $$tmpdir/$$lang.new.po; \
302	fi
303
304$(DUMMYPOFILES):
305
306update-gmo: Makefile $(GMOFILES)
307	@:
308
309Makefile: Makefile.in.in $(top_builddir)/config.status POTFILES.in
310	cd $(top_builddir) \
311	  && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
312	       $(SHELL) ./config.status
313
314force:
315
316# Tell versions [3.59,3.63) of GNU make not to export all variables.
317# Otherwise a system limit (for SysV at least) may be exceeded.
318.NOEXPORT:
319