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@
24 localedir = $(datadir)/locale
25 gettextsrcdir = $(datadir)/gettext/po
28 INSTALL_DATA = @INSTALL_DATA@
29 mkinstalldirs = mkdir -m 0755 -p --
35 MSGMERGE_UPDATE = @MSGMERGE@ --update
42 UPDATEPOFILES = @UPDATEPOFILES@
43 DUMMYPOFILES = @DUMMYPOFILES@
44 DISTFILES.common = Makefile.in.in remove-potcdate.sin \
45 $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
46 DISTFILES = $(DISTFILES.common) Makevars POTFILES.in $(DOMAIN).pot stamp-po \
47 $(POFILES) $(GMOFILES) \
48 $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
54 # Makevars gets inserted here. (Don't remove this line!)
57 .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-update
60 @echo "$(MSGFMT) -c -o $@ $<"; \
61 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
64 @lang=`echo $* | sed -e 's,.*/,,'`; \
65 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
66 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
67 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
70 sed -e '/^#/d' $< > t-$@
79 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
80 # been loosely updated. Its purpose is that when a developer or translator
81 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
82 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
83 # invocations of "make" will do nothing. This timestamp would not be necessary
84 # if updating the $(CATALOGS) would always touch them; however, the rule for
85 # $(POFILES) has been designed to not touch files that don't need to be
87 stamp-po: $(srcdir)/$(DOMAIN).pot
88 test -z "$(CATALOGS)" || $(MAKE) $(CATALOGS)
89 @echo "touch stamp-po"
90 @echo timestamp > stamp-poT
91 @mv stamp-poT stamp-po
93 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
94 # otherwise packages like GCC can not be built if only parts of the source
95 # have been downloaded.
97 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
98 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
99 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
100 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
101 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
102 --files-from=$(srcdir)/POTFILES.in \
103 --copyright-holder='$(COPYRIGHT_HOLDER)' \
104 --msgid-bugs-address='$(MSGID_BUGS_ADDRESS)'
105 test ! -f $(DOMAIN).po || { \
106 if test -f $(srcdir)/$(DOMAIN).pot; then \
107 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
108 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
109 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
110 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
112 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
113 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
116 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
120 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
121 # every "make" invocation, only create it when it is missing.
122 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
123 $(srcdir)/$(DOMAIN).pot:
124 $(MAKE) $(DOMAIN).pot-update
126 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
127 # Note that a PO file is not touched if it doesn't need to be changed.
128 $(POFILES): $(srcdir)/$(DOMAIN).pot
129 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
130 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
131 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
132 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot
135 install: install-exec install-data
137 install-data: install-data-@USE_NLS@
138 if test "$(PACKAGE)" = "gettext-tools"; then \
139 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
140 for file in $(DISTFILES.common) Makevars.template; do \
141 $(INSTALL_DATA) $(srcdir)/$$file \
142 $(DESTDIR)$(gettextsrcdir)/$$file; \
144 for file in Makevars; do \
145 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
151 install-data-yes: all
152 $(mkinstalldirs) $(DESTDIR)$(datadir)
153 @catalogs='$(CATALOGS)'; \
154 for cat in $$catalogs; do \
155 cat=`basename $$cat`; \
156 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
157 dir=$(localedir)/$$lang/LC_MESSAGES; \
158 $(mkinstalldirs) $(DESTDIR)$$dir; \
159 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
160 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
161 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
162 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
163 if test -n "$$lc"; then \
164 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
165 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
166 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
167 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
168 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
170 if test -f $$file; then \
171 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
174 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
176 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
179 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
180 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
183 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
184 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
185 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
186 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
187 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
192 install-strip: install
194 installdirs: installdirs-exec installdirs-data
196 installdirs-data: installdirs-data-@USE_NLS@
197 if test "$(PACKAGE)" = "gettext-tools"; then \
198 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
203 installdirs-data-yes:
204 $(mkinstalldirs) $(DESTDIR)$(datadir)
205 @catalogs='$(CATALOGS)'; \
206 for cat in $$catalogs; do \
207 cat=`basename $$cat`; \
208 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
209 dir=$(localedir)/$$lang/LC_MESSAGES; \
210 $(mkinstalldirs) $(DESTDIR)$$dir; \
211 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
212 if test -n "$$lc"; then \
213 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
214 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
215 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
216 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
217 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
219 if test -f $$file; then \
220 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
223 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
225 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
228 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
229 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
236 # Define this as empty until I found a useful application.
239 uninstall: uninstall-exec uninstall-data
241 uninstall-data: uninstall-data-@USE_NLS@
242 if test "$(PACKAGE)" = "gettext-tools"; then \
243 for file in $(DISTFILES.common) Makevars.template; do \
244 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
251 catalogs='$(CATALOGS)'; \
252 for cat in $$catalogs; do \
253 cat=`basename $$cat`; \
254 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
255 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
256 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
262 info dvi ps pdf html tags TAGS ctags CTAGS ID:
265 rm -f remove-potcdate.sed
267 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
273 rm -f Makefile Makefile.in POTFILES *.mo
275 maintainer-clean: distclean
276 @echo "This command is intended for maintainers to use;"
277 @echo "it deletes files that may require special tools to rebuild."
278 rm -f stamp-po $(GMOFILES)
280 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
284 # This is a separate target because 'update-po' must be executed before.
286 dists="$(DISTFILES)"; \
287 if test "$(PACKAGE)" = "gettext-tools"; then \
288 dists="$$dists Makevars.template"; \
290 if test -f $(srcdir)/ChangeLog; then \
291 dists="$$dists ChangeLog"; \
293 for i in 0 1 2 3 4 5 6 7 8 9; do \
294 if test -f $(srcdir)/ChangeLog.$$i; then \
295 dists="$$dists ChangeLog.$$i"; \
298 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
299 for file in $$dists; do \
300 if test -f $$file; then \
301 cp -p $$file $(distdir); \
303 cp -p $(srcdir)/$$file $(distdir); \
308 $(MAKE) $(DOMAIN).pot-update
309 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
312 # General rule for updating PO files.
315 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
316 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
319 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
320 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
322 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
323 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
324 rm -f $$tmpdir/$$lang.new.po; \
326 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
329 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
334 echo "msgmerge for $$lang.po failed!" 1>&2; \
335 rm -f $$tmpdir/$$lang.new.po; \
340 update-gmo: Makefile $(GMOFILES)
343 Makefile: Makefile.in.in $(top_builddir)/config.status @POMAKEFILEDEPS@
345 && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
346 $(SHELL) ./config.status
350 # Tell versions [3.59,3.63) of GNU make not to export all variables.
351 # Otherwise a system limit (for SysV at least) may be exceeded.