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