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> 3# 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 7# functionality. 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. 10# 11# Origin: gettext-0.15 12 13PACKAGE = @PACKAGE@ 14VERSION = @VERSION@ 15PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 16 17SHELL = /bin/sh 18@SET_MAKE@ 19 20srcdir = @srcdir@ 21top_srcdir = @top_srcdir@ 22VPATH = @srcdir@ 23 24prefix = @prefix@ 25exec_prefix = @exec_prefix@ 26datarootdir = @datarootdir@ 27datadir = @datadir@ 28localedir = @localedir@ 29gettextsrcdir = $(datadir)/gettext/po 30 31INSTALL = @INSTALL@ 32INSTALL_DATA = @INSTALL_DATA@ 33mkinstalldirs = $(SHELL) @install_sh@ -d 34mkdir_p = @mkdir_p@ 35 36GMSGFMT_ = @GMSGFMT@ 37GMSGFMT_no = @GMSGFMT@ 38GMSGFMT_yes = @GMSGFMT_015@ 39GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT)) 40MSGFMT_ = @MSGFMT@ 41MSGFMT_no = @MSGFMT@ 42MSGFMT_yes = @MSGFMT_015@ 43MSGFMT = $(MSGFMT_$(USE_MSGCTXT)) 44XGETTEXT_ = @XGETTEXT@ 45XGETTEXT_no = @XGETTEXT@ 46XGETTEXT_yes = @XGETTEXT_015@ 47XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT)) 48MSGMERGE = msgmerge 49MSGMERGE_UPDATE = @MSGMERGE@ --update 50MSGINIT = msginit 51MSGCONV = msgconv 52MSGFILTER = msgfilter 53 54POFILES = @POFILES@ 55GMOFILES = @GMOFILES@ 56UPDATEPOFILES = @UPDATEPOFILES@ 57DUMMYPOFILES = @DUMMYPOFILES@ 58DISTFILES.common = Makefile.in.in remove-potcdate.sin \ 59$(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3) 60DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \ 61$(POFILES) $(GMOFILES) \ 62$(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3) 63 64POTFILES = \ 65 66CATALOGS = @CATALOGS@ 67 68# Makevars gets inserted here. (Don't remove this line!) 69 70.SUFFIXES: 71.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update 72 73.po.mo: 74 @echo "$(MSGFMT) -c -o $@ $<"; \ 75 $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@ 76 77.po.gmo: 78 @lang=`echo $* | sed -e 's,.*/,,'`; \ 79 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 80 echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \ 81 cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo 82 83.sin.sed: 84 sed -e '/^#/d' $< > t-$@ 85 mv t-$@ $@ 86 87 88all: all-@USE_NLS@ 89 90all-yes: stamp-po 91all-no: 92 93# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no 94# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because 95# we don't want to bother translators with empty POT files). We assume that 96# LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty. 97# In this case, stamp-po is a nop (i.e. a phony target). 98 99# stamp-po is a timestamp denoting the last time at which the CATALOGS have 100# been loosely updated. Its purpose is that when a developer or translator 101# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS, 102# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent 103# invocations of "make" will do nothing. This timestamp would not be necessary 104# if updating the $(CATALOGS) would always touch them; however, the rule for 105# $(POFILES) has been designed to not touch files that don't need to be 106# changed. 107stamp-po: $(srcdir)/$(DOMAIN).pot 108 test ! -f $(srcdir)/$(DOMAIN).pot || \ 109 test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES) 110 @test ! -f $(srcdir)/$(DOMAIN).pot || { \ 111 echo "touch stamp-po" && \ 112 echo timestamp > stamp-poT && \ 113 mv stamp-poT stamp-po; \ 114 } 115 116# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update', 117# otherwise packages like GCC can not be built if only parts of the source 118# have been downloaded. 119 120# This target rebuilds $(DOMAIN).pot; it is an expensive operation. 121# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. 122$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed 123 if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \ 124 msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \ 125 else \ 126 msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \ 127 fi; \ 128 $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ 129 --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \ 130 --files-from=$(srcdir)/POTFILES.in \ 131 --copyright-holder='$(COPYRIGHT_HOLDER)' \ 132 --msgid-bugs-address="$$msgid_bugs_address" 133 test ! -f $(DOMAIN).po || { \ 134 if test -f $(srcdir)/$(DOMAIN).pot; then \ 135 sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ 136 sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ 137 if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \ 138 rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \ 139 else \ 140 rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \ 141 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ 142 fi; \ 143 else \ 144 mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ 145 fi; \ 146 } 147 148# This rule has no dependencies: we don't need to update $(DOMAIN).pot at 149# every "make" invocation, only create it when it is missing. 150# Only "make $(DOMAIN).pot-update" or "make dist" will force an update. 151$(srcdir)/$(DOMAIN).pot: 152 $(MAKE) $(DOMAIN).pot-update 153 154# This target rebuilds a PO file if $(DOMAIN).pot has changed. 155# Note that a PO file is not touched if it doesn't need to be changed. 156$(POFILES): $(srcdir)/$(DOMAIN).pot 157 @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ 158 if test -f "$(srcdir)/$${lang}.po"; then \ 159 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 160 echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \ 161 cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \ 162 else \ 163 $(MAKE) $${lang}.po-create; \ 164 fi 165 166 167install: install-exec install-data 168install-exec: 169install-data: install-data-@USE_NLS@ 170 if test "$(PACKAGE)" = "gettext-tools"; then \ 171 $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ 172 for file in $(DISTFILES.common) Makevars.template; do \ 173 $(INSTALL_DATA) $(srcdir)/$$file \ 174 $(DESTDIR)$(gettextsrcdir)/$$file; \ 175 done; \ 176 for file in Makevars; do \ 177 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ 178 done; \ 179 else \ 180 : ; \ 181 fi 182install-data-no: all 183install-data-yes: all 184 $(mkdir_p) $(DESTDIR)$(datadir) 185 @catalogs='$(CATALOGS)'; \ 186 for cat in $$catalogs; do \ 187 cat=`basename $$cat`; \ 188 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ 189 dir=$(localedir)/$$lang/LC_MESSAGES; \ 190 $(mkdir_p) $(DESTDIR)$$dir; \ 191 if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \ 192 $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \ 193 echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \ 194 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ 195 if test -n "$$lc"; then \ 196 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ 197 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ 198 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ 199 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ 200 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ 201 for file in *; do \ 202 if test -f $$file; then \ 203 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ 204 fi; \ 205 done); \ 206 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ 207 else \ 208 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ 209 :; \ 210 else \ 211 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ 212 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ 213 fi; \ 214 fi; \ 215 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ 216 ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ 217 ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ 218 cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ 219 echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \ 220 fi; \ 221 done; \ 222 done 223 224install-strip: install 225 226installdirs: installdirs-exec installdirs-data 227installdirs-exec: 228installdirs-data: installdirs-data-@USE_NLS@ 229 if test "$(PACKAGE)" = "gettext-tools"; then \ 230 $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ 231 else \ 232 : ; \ 233 fi 234installdirs-data-no: 235installdirs-data-yes: 236 $(mkdir_p) $(DESTDIR)$(datadir) 237 @catalogs='$(CATALOGS)'; \ 238 for cat in $$catalogs; do \ 239 cat=`basename $$cat`; \ 240 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ 241 dir=$(localedir)/$$lang/LC_MESSAGES; \ 242 $(mkdir_p) $(DESTDIR)$$dir; \ 243 for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ 244 if test -n "$$lc"; then \ 245 if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ 246 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ 247 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ 248 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ 249 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ 250 for file in *; do \ 251 if test -f $$file; then \ 252 ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ 253 fi; \ 254 done); \ 255 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ 256 else \ 257 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ 258 :; \ 259 else \ 260 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ 261 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ 262 fi; \ 263 fi; \ 264 fi; \ 265 done; \ 266 done 267 268# Define this as empty until I found a useful application. 269installcheck: 270 271uninstall: uninstall-exec uninstall-data 272uninstall-exec: 273uninstall-data: uninstall-data-@USE_NLS@ 274 if test "$(PACKAGE)" = "gettext-tools"; then \ 275 for file in $(DISTFILES.common) Makevars.template; do \ 276 rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ 277 done; \ 278 else \ 279 : ; \ 280 fi 281uninstall-data-no: 282uninstall-data-yes: 283 catalogs='$(CATALOGS)'; \ 284 for cat in $$catalogs; do \ 285 cat=`basename $$cat`; \ 286 lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ 287 for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \ 288 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ 289 done; \ 290 done 291 292check: all 293 294info dvi ps pdf html tags TAGS ctags CTAGS ID: 295 296mostlyclean: 297 rm -f remove-potcdate.sed 298 rm -f stamp-poT 299 rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po 300 rm -fr *.o 301 302clean: mostlyclean 303 304distclean: clean 305 rm -f Makefile Makefile.in POTFILES *.mo 306 307maintainer-clean: distclean 308 @echo "This command is intended for maintainers to use;" 309 @echo "it deletes files that may require special tools to rebuild." 310 rm -f stamp-po $(GMOFILES) 311 312distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) 313dist distdir: 314 $(MAKE) update-po 315 @$(MAKE) dist2 316# This is a separate target because 'update-po' must be executed before. 317dist2: stamp-po $(DISTFILES) 318 dists="$(DISTFILES)"; \ 319 if test "$(PACKAGE)" = "gettext-tools"; then \ 320 dists="$$dists Makevars.template"; \ 321 fi; \ 322 if test -f $(srcdir)/$(DOMAIN).pot; then \ 323 dists="$$dists $(DOMAIN).pot stamp-po"; \ 324 fi; \ 325 if test -f $(srcdir)/ChangeLog; then \ 326 dists="$$dists ChangeLog"; \ 327 fi; \ 328 for i in 0 1 2 3 4 5 6 7 8 9; do \ 329 if test -f $(srcdir)/ChangeLog.$$i; then \ 330 dists="$$dists ChangeLog.$$i"; \ 331 fi; \ 332 done; \ 333 if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \ 334 for file in $$dists; do \ 335 if test -f $$file; then \ 336 cp -p $$file $(distdir) || exit 1; \ 337 else \ 338 cp -p $(srcdir)/$$file $(distdir) || exit 1; \ 339 fi; \ 340 done 341 342update-po: Makefile 343 $(MAKE) $(DOMAIN).pot-update 344 test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES) 345 $(MAKE) update-gmo 346 347# General rule for creating PO files. 348 349.nop.po-create: 350 @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \ 351 echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \ 352 exit 1 353 354# General rule for updating PO files. 355 356.nop.po-update: 357 @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \ 358 if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \ 359 tmpdir=`pwd`; \ 360 echo "$$lang:"; \ 361 test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ 362 echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ 363 cd $(srcdir); \ 364 if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \ 365 if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ 366 rm -f $$tmpdir/$$lang.new.po; \ 367 else \ 368 if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ 369 :; \ 370 else \ 371 echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ 372 exit 1; \ 373 fi; \ 374 fi; \ 375 else \ 376 echo "msgmerge for $$lang.po failed!" 1>&2; \ 377 rm -f $$tmpdir/$$lang.new.po; \ 378 fi 379 380$(DUMMYPOFILES): 381 382update-gmo: Makefile $(GMOFILES) 383 @: 384 385Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@ 386 cd $(top_builddir) \ 387 && $(SHELL) ./config.status $(subdir)/$@.in po-directories 388 389force: 390 391# Tell versions [3.59,3.63) of GNU make not to export all variables. 392# Otherwise a system limit (for SysV at least) may be exceeded. 393.NOEXPORT: 394