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.
11 PACKAGE = @PACKAGE_NAME@
12 VERSION = @PACKAGE_VERSION@
18 top_srcdir = @top_srcdir@
22 BUILD_DIR = @BUILD_DIR@
25 exec_prefix = @exec_prefix@
27 localedir = $(datadir)/locale
28 gettextsrcdir = $(datadir)/gettext/po
31 INSTALL_DATA = @INSTALL_DATA@
32 MKINSTALLDIRS = @MKINSTALLDIRS@
33 mkinstalldirs = $(SHELL) $(MKINSTALLDIRS)
39 MSGMERGE_UPDATE = @MSGMERGE@ --update
46 UPDATEPOFILES = @UPDATEPOFILES@
47 DUMMYPOFILES = @DUMMYPOFILES@
48 DISTFILES.common = Makefile.in.in remove-potcdate.sin \
49 $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
50 DISTFILES = $(DISTFILES.common) Makevars POTFILES.in $(DOMAIN).pot stamp-po \
51 $(POFILES) $(GMOFILES) \
52 $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
58 # Makevars gets inserted here. (Don't remove this line!)
61 .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-update
64 @echo "$(MSGFMT) -c -o $@ $<"; \
65 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
68 @lang=`echo $* | sed -e 's,.*/,,'`; \
69 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
70 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
71 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
74 sed -e '/^#/d' $< > t-$@
83 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
84 # been loosely updated. Its purpose is that when a developer or translator
85 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
86 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
87 # invocations of "make" will do nothing. This timestamp would not be necessary
88 # if updating the $(CATALOGS) would always touch them; however, the rule for
89 # $(POFILES) has been designed to not touch files that don't need to be
91 stamp-po: $(srcdir)/$(DOMAIN).pot
92 test -z "$(CATALOGS)" || $(MAKE) $(CATALOGS)
93 @echo "touch stamp-po"
94 @echo timestamp > stamp-poT
95 @mv stamp-poT stamp-po
97 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
98 # otherwise packages like GCC can not be built if only parts of the source
99 # have been downloaded.
101 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
102 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
103 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
104 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
105 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
106 --files-from=$(srcdir)/POTFILES.in \
107 --copyright-holder='$(COPYRIGHT_HOLDER)' \
108 --msgid-bugs-address='$(MSGID_BUGS_ADDRESS)'
109 $(MAKE) $(MFLAGS) builtins.pot-update
110 test ! -f $(DOMAIN).po || { \
111 if test -f $(srcdir)/$(DOMAIN).pot; then \
112 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
113 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
114 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
115 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
117 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
118 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
121 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
125 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
126 # every "make" invocation, only create it when it is missing.
127 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
128 $(srcdir)/$(DOMAIN).pot:
129 $(MAKE) $(DOMAIN).pot-update
131 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
132 # Note that a PO file is not touched if it doesn't need to be changed.
133 $(POFILES): $(srcdir)/$(DOMAIN).pot
134 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
135 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
136 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
137 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot
140 install: install-exec install-data
142 install-data: install-data-@USE_NLS@
143 if test "$(PACKAGE)" = "gettext-tools"; then \
144 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
145 for file in $(DISTFILES.common) Makevars.template; do \
146 $(INSTALL_DATA) $(srcdir)/$$file \
147 $(DESTDIR)$(gettextsrcdir)/$$file; \
149 for file in Makevars; do \
150 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
156 install-data-yes: all
157 $(mkinstalldirs) $(DESTDIR)$(datadir)
158 @catalogs='$(CATALOGS)'; \
159 for cat in $$catalogs; do \
160 cat=`basename $$cat`; \
161 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
162 dir=$(localedir)/$$lang/LC_MESSAGES; \
163 $(mkinstalldirs) $(DESTDIR)$$dir; \
164 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
165 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
166 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
167 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
168 if test -n "$$lc"; then \
169 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
170 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
171 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
172 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
173 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
175 if test -f $$file; then \
176 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
179 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
181 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
184 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
185 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
188 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
189 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
190 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
191 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
192 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
197 install-strip: install
199 installdirs: installdirs-exec installdirs-data
201 installdirs-data: installdirs-data-@USE_NLS@
202 if test "$(PACKAGE)" = "gettext-tools"; then \
203 $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \
208 installdirs-data-yes:
209 $(mkinstalldirs) $(DESTDIR)$(datadir)
210 @catalogs='$(CATALOGS)'; \
211 for cat in $$catalogs; do \
212 cat=`basename $$cat`; \
213 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
214 dir=$(localedir)/$$lang/LC_MESSAGES; \
215 $(mkinstalldirs) $(DESTDIR)$$dir; \
216 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
217 if test -n "$$lc"; then \
218 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
219 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
220 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
221 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
222 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
224 if test -f $$file; then \
225 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
228 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
230 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
233 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
234 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
241 # Define this as empty until I found a useful application.
244 uninstall: uninstall-exec uninstall-data
246 uninstall-data: uninstall-data-@USE_NLS@
247 if test "$(PACKAGE)" = "gettext-tools"; then \
248 for file in $(DISTFILES.common) Makevars.template; do \
249 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
256 catalogs='$(CATALOGS)'; \
257 for cat in $$catalogs; do \
258 cat=`basename $$cat`; \
259 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
260 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
261 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
267 info dvi ps pdf html tags TAGS ctags CTAGS ID:
270 rm -f remove-potcdate.sed
272 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
278 rm -f Makefile Makefile.in POTFILES *.mo
280 maintainer-clean: distclean
281 @echo "This command is intended for maintainers to use;"
282 @echo "it deletes files that may require special tools to rebuild."
283 rm -f stamp-po $(GMOFILES)
285 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
289 # This is a separate target because 'update-po' must be executed before.
291 dists="$(DISTFILES)"; \
292 if test "$(PACKAGE)" = "gettext-tools"; then \
293 dists="$$dists Makevars.template"; \
295 if test -f $(srcdir)/ChangeLog; then \
296 dists="$$dists ChangeLog"; \
298 for i in 0 1 2 3 4 5 6 7 8 9; do \
299 if test -f $(srcdir)/ChangeLog.$$i; then \
300 dists="$$dists ChangeLog.$$i"; \
303 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
304 for file in $$dists; do \
305 if test -f $$file; then \
306 cp -p $$file $(distdir); \
308 cp -p $(srcdir)/$$file $(distdir); \
313 $(MAKE) $(DOMAIN).pot-update
314 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
317 # General rule for updating PO files.
320 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
321 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
324 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
325 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
327 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
328 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
329 rm -f $$tmpdir/$$lang.new.po; \
331 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
334 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
339 echo "msgmerge for $$lang.po failed!" 1>&2; \
340 rm -f $$tmpdir/$$lang.new.po; \
345 update-gmo: Makefile $(GMOFILES)
348 Makefile: Makefile.in.in $(top_builddir)/config.status @POMAKEFILEDEPS@ $(srcdir)/Rules-builtins
350 && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
351 $(SHELL) ./config.status
355 # Tell versions [3.59,3.63) of GNU make not to export all variables.
356 # Otherwise a system limit (for SysV at least) may be exceeded.