1 # Makefile for PO directory in any package using GNU gettext.
2 # Copyright (C) 1995-1997, 2000-2003 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) $(MKINSTALLDIRS)
37 MSGMERGE_UPDATE = @MSGMERGE@ --update
44 UPDATEPOFILES = @UPDATEPOFILES@
45 DUMMYPOFILES = @DUMMYPOFILES@
46 DISTFILES.common = Makefile.in.in remove-potcdate.sin \
47 $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
48 DISTFILES = $(DISTFILES.common) Makevars POTFILES.in $(DOMAIN).pot stamp-po \
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 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
82 # been loosely updated. Its purpose is that when a developer or translator
83 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
84 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
85 # invocations of "make" will do nothing. This timestamp would not be necessary
86 # if updating the $(CATALOGS) would always touch them; however, the rule for
87 # $(POFILES) has been designed to not touch files that don't need to be
89 stamp-po: $(srcdir)/$(DOMAIN).pot
90 test -z "$(CATALOGS)" || $(MAKE) $(CATALOGS)
91 @echo "touch stamp-po"
92 @echo timestamp > stamp-poT
93 @mv stamp-poT stamp-po
95 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
96 # otherwise packages like GCC can not be built if only parts of the source
97 # have been downloaded.
99 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
100 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
101 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
102 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
103 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
104 --files-from=$(srcdir)/POTFILES.in \
105 --copyright-holder='$(COPYRIGHT_HOLDER)' \
106 --msgid-bugs-address='$(MSGID_BUGS_ADDRESS)'
107 test ! -f $(DOMAIN).po || { \
108 if test -f $(srcdir)/$(DOMAIN).pot; then \
109 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
110 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
111 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
112 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
114 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
115 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
118 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
122 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
123 # every "make" invocation, only create it when it is missing.
124 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
125 $(srcdir)/$(DOMAIN).pot:
126 $(MAKE) $(DOMAIN).pot-update
128 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
129 # Note that a PO file is not touched if it doesn't need to be changed.
130 $(POFILES): $(srcdir)/$(DOMAIN).pot
131 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
132 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
133 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
134 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot
137 install: install-exec install-data
139 install-data: install-data-@USE_NLS@
140 if test "$(PACKAGE)" = "gettext-tools"; then \
141 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
142 for file in $(DISTFILES.common) Makevars.template; do \
143 $(INSTALL_DATA) $(srcdir)/$$file \
144 $(DESTDIR)$(gettextsrcdir)/$$file; \
146 for file in Makevars; do \
147 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
153 install-data-yes: all
154 $(mkinstalldirs) $(DESTDIR)$(datadir)
155 @catalogs='$(CATALOGS)'; \
156 for cat in $$catalogs; do \
157 cat=`basename $$cat`; \
158 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
159 dir=$(localedir)/$$lang/LC_MESSAGES; \
160 $(mkinstalldirs) $(DESTDIR)$$dir; \
161 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
162 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
163 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
164 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
165 if test -n "$$lc"; then \
166 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
167 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
168 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
169 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
170 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
172 if test -f $$file; then \
173 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
176 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
178 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
181 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
182 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
185 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
186 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
187 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
188 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
189 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
194 install-strip: install
196 installdirs: installdirs-exec installdirs-data
198 installdirs-data: installdirs-data-@USE_NLS@
199 if test "$(PACKAGE)" = "gettext-tools"; then \
200 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
205 installdirs-data-yes:
206 $(mkinstalldirs) $(DESTDIR)$(datadir)
207 @catalogs='$(CATALOGS)'; \
208 for cat in $$catalogs; do \
209 cat=`basename $$cat`; \
210 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
211 dir=$(localedir)/$$lang/LC_MESSAGES; \
212 $(mkinstalldirs) $(DESTDIR)$$dir; \
213 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
214 if test -n "$$lc"; then \
215 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
216 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
217 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
218 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
219 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
221 if test -f $$file; then \
222 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
225 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
227 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
230 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
231 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
238 # Define this as empty until I found a useful application.
241 uninstall: uninstall-exec uninstall-data
243 uninstall-data: uninstall-data-@USE_NLS@
244 if test "$(PACKAGE)" = "gettext-tools"; then \
245 for file in $(DISTFILES.common) Makevars.template; do \
246 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
253 catalogs='$(CATALOGS)'; \
254 for cat in $$catalogs; do \
255 cat=`basename $$cat`; \
256 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
257 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
258 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
264 info dvi ps pdf html tags TAGS ctags CTAGS ID:
267 rm -f remove-potcdate.sed
269 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
275 rm -f Makefile Makefile.in POTFILES *.mo
277 maintainer-clean: distclean
278 @echo "This command is intended for maintainers to use;"
279 @echo "it deletes files that may require special tools to rebuild."
280 rm -f stamp-po $(GMOFILES)
282 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
286 # This is a separate target because 'update-po' must be executed before.
288 dists="$(DISTFILES)"; \
289 if test "$(PACKAGE)" = "gettext-tools"; then \
290 dists="$$dists Makevars.template"; \
292 if test -f $(srcdir)/ChangeLog; then \
293 dists="$$dists ChangeLog"; \
295 for i in 0 1 2 3 4 5 6 7 8 9; do \
296 if test -f $(srcdir)/ChangeLog.$$i; then \
297 dists="$$dists ChangeLog.$$i"; \
300 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
301 for file in $$dists; do \
302 if test -f $$file; then \
303 cp -p $$file $(distdir); \
305 cp -p $(srcdir)/$$file $(distdir); \
310 $(MAKE) $(DOMAIN).pot-update
311 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
314 # General rule for updating PO files.
317 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
318 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
321 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
322 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
324 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
325 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
326 rm -f $$tmpdir/$$lang.new.po; \
328 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
331 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
336 echo "msgmerge for $$lang.po failed!" 1>&2; \
337 rm -f $$tmpdir/$$lang.new.po; \
342 update-gmo: Makefile $(GMOFILES)
345 Makefile: Makefile.in.in $(top_builddir)/config.status @POMAKEFILEDEPS@
347 && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
348 $(SHELL) ./config.status
352 # Tell versions [3.59,3.63) of GNU make not to export all variables.
353 # Otherwise a system limit (for SysV at least) may be exceeded.