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>
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
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.
18 top_srcdir = @top_srcdir@
22 exec_prefix = @exec_prefix@
23 datarootdir = @datarootdir@
25 localedir = $(datadir)/locale
26 gettextsrcdir = $(datadir)/gettext/po
29 INSTALL_DATA = @INSTALL_DATA@
30 MKINSTALLDIRS = @MKINSTALLDIRS@
31 mkinstalldirs = $(SHELL) `case "$(MKINSTALLDIRS)" in /*) echo "$(MKINSTALLDIRS)" ;; *) echo "$(top_builddir)/$(MKINSTALLDIRS)" ;; esac`
37 MSGMERGE_UPDATE = @MSGMERGE@ --update
44 UPDATEPOFILES = @UPDATEPOFILES@
45 DUMMYPOFILES = @DUMMYPOFILES@
46 DISTFILES.common = Makefile.in.in Makevars remove-potcdate.sin \
47 $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
48 DISTFILES = $(DISTFILES.common) POTFILES.in $(DOMAIN).pot \
49 $(POFILES) $(GMOFILES) \
50 $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
56 # Makevars gets inserted here. (Don't remove this line!)
59 .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-update
62 @echo "$(MSGFMT) -c -o $@ $<"; \
63 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
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
72 sed -e '/^#/d' $< > t-$@
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.
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; \
97 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
98 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
101 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
105 $(srcdir)/$(DOMAIN).pot:
106 $(MAKE) $(DOMAIN).pot-update
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
115 install: install-exec install-data
117 install-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; \
128 install-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 && \
147 if test -f $$file; then \
148 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
151 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
153 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
156 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
157 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
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"; \
169 install-strip: install
171 installdirs: installdirs-exec installdirs-data
173 installdirs-data: installdirs-data-@USE_NLS@
174 if test "$(PACKAGE)" = "gettext"; then \
175 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
180 installdirs-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 && \
196 if test -f $$file; then \
197 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
200 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
202 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
205 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
206 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
213 # Define this as empty until I found a useful application.
216 uninstall: uninstall-exec uninstall-data
218 uninstall-data: uninstall-data-@USE_NLS@
219 if test "$(PACKAGE)" = "gettext"; then \
220 for file in $(DISTFILES.common); do \
221 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
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; \
239 dvi info tags TAGS ID:
242 rm -f remove-potcdate.sed
243 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
249 rm -f Makefile Makefile.in POTFILES *.mo
251 maintainer-clean: distclean
252 @echo "This command is intended for maintainers to use;"
253 @echo "it deletes files that may require special tools to rebuild."
256 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
260 # This is a separate target because 'update-po' must be executed before.
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); \
269 cp -p $(srcdir)/$$file $(distdir); \
274 $(MAKE) $(DOMAIN).pot-update
275 $(MAKE) $(UPDATEPOFILES)
278 # General rule for updating PO files.
281 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
282 if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; fi; \
285 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
286 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
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; \
292 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
295 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
300 echo "msgmerge for $$lang.po failed!" 1>&2; \
301 rm -f $$tmpdir/$$lang.new.po; \
306 update-gmo: Makefile $(GMOFILES)
309 Makefile: Makefile.in.in $(top_builddir)/config.status POTFILES.in
311 && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
312 $(SHELL) ./config.status
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.