1 # Makefile for PO directory in any package using GNU gettext.
2 # Copyright (C) 1995-1997, 2000-2006 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.
11 # Origin: gettext-0.16
12 # Modified to handle translations with xml2po by Nicolas François - 2007
16 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
22 top_srcdir = @top_srcdir@
27 MSGFMT_yes = @MSGFMT_015@
28 MSGFMT = $(MSGFMT_$(USE_MSGCTXT))
29 XGETTEXT_ = @XGETTEXT@
30 XGETTEXT_no = @XGETTEXT@
31 XGETTEXT_yes = @XGETTEXT_015@
32 XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT))
33 MSGMERGE = @MSGMERGE@ --previous
34 MSGMERGE_UPDATE = @MSGMERGE@ --update --previous
39 include $(srcdir)/LINGUAS
40 DISTFILES = $(srcdir)/Makevars $(srcdir)/XMLFILES $(srcdir)/LINGUAS $(POFILES)
42 include $(srcdir)/XMLFILES
44 include $(srcdir)/Makevars
47 .SUFFIXES: .po .sed .sin .nop .po-create .po-update
49 remove-potcdate.sin: $(top_srcdir)/po/remove-potcdate.sin
53 sed -e '/^#/d' $< > t-$@
61 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
62 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
63 # we don't want to bother translators with empty POT files). We assume that
64 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
65 # In this case, stamp-po is a nop (i.e. a phony target).
67 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
68 # been loosely updated. Its purpose is that when a developer or translator
69 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
70 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
71 # invocations of "make" will do nothing. This timestamp would not be necessary
72 # if updating the $(CATALOGS) would always touch them; however, the rule for
73 # $(POFILES) has been designed to not touch files that don't need to be
75 stamp-po: $(srcdir)/$(DOMAIN).pot
77 @test ! -f $(srcdir)/$(DOMAIN).pot || { \
78 echo "touch stamp-po" && \
79 echo timestamp > stamp-poT && \
80 mv stamp-poT stamp-po; \
83 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
84 # otherwise packages like GCC can not be built if only parts of the source
85 # have been downloaded.
87 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
88 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
89 # TODO: set MSGID_BUGS_ADDRESS, COPYRIGHT_HOLDER
90 $(DOMAIN).pot-update: $(XMLFILES) $(srcdir)/XMLFILES remove-potcdate.sed
91 @set -e; tmpdir=`pwd`; \
92 echo "cd $(top_srcdir)/man"; \
93 cd $(top_srcdir)/man; \
94 echo "xml2po --expand-all-entities -o $$tmpdir/$(DOMAIN).po $(notdir $(XMLFILES))"; \
95 xml2po --expand-all-entities -o $$tmpdir/$(DOMAIN).po $(notdir $(XMLFILES)); \
97 test ! -f $(DOMAIN).po || { \
98 if test -f $(srcdir)/$(DOMAIN).pot; then \
99 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
100 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
101 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
102 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
104 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
105 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
108 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
112 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
113 # every "make" invocation, only create it when it is missing.
114 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
115 $(srcdir)/$(DOMAIN).pot:
116 $(MAKE) $(DOMAIN).pot-update
118 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
119 # Note that a PO file is not touched if it doesn't need to be changed.
120 $(POFILES): $(srcdir)/$(DOMAIN).pot
121 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
122 if test -f "$(srcdir)/$${lang}.po"; then \
123 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
124 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
125 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
127 $(MAKE) $${lang}.po-create; \
131 install: install-exec install-data
135 install-strip: install
137 installdirs: installdirs-exec installdirs-data
141 # Define this as empty until I found a useful application.
144 uninstall: uninstall-exec uninstall-data
150 info dvi ps pdf html tags TAGS ctags CTAGS ID:
153 rm -f remove-potcdate.sed remove-potcdate.sin
155 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
162 maintainer-clean: distclean
163 @echo "This command is intended for maintainers to use;"
164 @echo "it deletes files that may require special tools to rebuild."
167 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
171 # This is a separate target because 'update-po' must be executed before.
172 dist2: stamp-po $(DISTFILES)
173 dists="$(DISTFILES)"; \
174 if test -f $(srcdir)/$(DOMAIN).pot; then \
175 dists="$$dists $(DOMAIN).pot stamp-po"; \
177 if test -f $(srcdir)/ChangeLog; then \
178 dists="$$dists ChangeLog"; \
180 for i in 0 1 2 3 4 5 6 7 8 9; do \
181 if test -f $(srcdir)/ChangeLog.$$i; then \
182 dists="$$dists ChangeLog.$$i"; \
185 for file in $$dists; do \
186 if test -f $$file; then \
187 cp -p $$file $(distdir) || exit 1; \
189 cp -p $(srcdir)/$$file $(distdir) || exit 1; \
194 $(MAKE) $(DOMAIN).pot-update
195 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
197 # General rule for creating PO files.
200 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
201 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
204 # General rule for updating PO files.
207 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
210 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
211 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
213 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
214 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
215 rm -f $$tmpdir/$$lang.new.po; \
217 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
220 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
225 echo "msgmerge for $$lang.po failed!" 1>&2; \
226 rm -f $$tmpdir/$$lang.new.po; \
232 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
235 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
237 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
238 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
241 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
242 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
244 # Tell versions [3.59,3.63) of GNU make not to export all variables.
245 # Otherwise a system limit (for SysV at least) may be exceeded.