Home | History | Annotate | Download | only in po
      1 # Gettext stuff; based on the contents of the Makefile.in.in file
      2 # distributed with GNU Gettext.
      3 #
      4 # The original copyright notice follows:
      5 #
      6 # Makefile for PO directory in any package using GNU gettext.
      7 # Copyright (C) 1995-1997, 2000-2007 by Ulrich Drepper <drepper (a] gnu.ai.mit.edu>
      8 #
      9 # This file can be copied and used freely without restrictions.  It can
     10 # be used in projects which are not available under the GNU General Public
     11 # License but which still want to provide support for the GNU gettext
     12 # functionality.
     13 # Please note that the actual code of GNU gettext is covered by the GNU
     14 # General Public License and is *not* in the public domain.
     15 #
     16 # Origin: gettext-0.17
     17 
     18 DOMAIN := $(GETTEXT_PACKAGE)
     19 
     20 MSGFMT := $(shell which msgfmt)
     21 
     22 XGETTEXT := $(shell which xgettext)
     23 
     24 MSGMERGE := $(shell which msgmerge)
     25 
     26 MSGMERGE_UPDATE := $(MSGMERGE) --update
     27 
     28 POFILES += $(shell ls $(srcdir)/WebKit/gtk/po/*.po)
     29 
     30 MOFILES += $(shell echo $(POFILES) | tr ' ' '\n' | sed "s,^$(srcdir)/,,g" | sed 's/\.po/.mo/g')
     31 
     32 .po.mo:
     33 	test -d WebKit/gtk/po/ || mkdir -p WebKit/gtk/po/
     34 	@echo "$(MSGFMT) -c -o $@ $<"; \
     35 	$(MSGFMT) -c -o $@ $<
     36 
     37 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
     38 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
     39 # we don't want to bother translators with empty POT files). We assume that
     40 # LINGUAS is empty in this case, i.e. $(POFILES) and $(MOFILES) are empty.
     41 # In this case, stamp-po is a nop (i.e. a phony target).
     42 
     43 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
     44 # been loosely updated. Its purpose is that when a developer or translator
     45 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
     46 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
     47 # invocations of "make" will do nothing. This timestamp would not be necessary
     48 # if updating the $(CATALOGS) would always touch them; however, the rule for
     49 # $(POFILES) has been designed to not touch files that don't need to be
     50 # changed.
     51 stamp-po: $(srcdir)/WebKit/gtk/po/$(DOMAIN).pot $(MOFILES)
     52 	test ! -f $(srcdir)/WebKit/gtk/po/$(DOMAIN).pot || \
     53 	  test -z "$(MOFILES)" || $(MAKE) $(MOFILES)
     54 	@test ! -f $(srcdir)/WebKit/gtk/po/$(DOMAIN).pot || { \
     55 	  echo "touch stamp-po" && \
     56 	  echo timestamp > stamp-poT && \
     57 	  mv stamp-poT stamp-po; \
     58 	}
     59 
     60 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
     61 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
     62 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/WebKit/gtk/po/POTFILES
     63 	package_gnu=''; \
     64 	if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
     65 	  msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
     66 	else \
     67 	  msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
     68 	fi; \
     69 	case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
     70 	  '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
     71 	    $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(srcdir) \
     72 	      --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
     73 	      --files-from=$(srcdir)/WebKit/gtk/po/POTFILES \
     74 	      --copyright-holder='$(COPYRIGHT_HOLDER)' \
     75 	      --msgid-bugs-address="$$msgid_bugs_address" \
     76 	      --keyword=_ --keyword=N_ -o $(srcdir)/WebKit/gtk/po/$(DOMAIN).pot \
     77 	    ;; \
     78 	  *) \
     79 	    $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(srcdir) \
     80 	      --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
     81 	      --files-from=$(srcdir)/WebKit/gtk/po/POTFILES \
     82 	      --copyright-holder='$(COPYRIGHT_HOLDER)' \
     83 	      --package-name="$${package_gnu}@PACKAGE@" \
     84 	      --package-version='@VERSION@' \
     85 	      --msgid-bugs-address="$$msgid_bugs_address" \
     86 	      --keyword=_ --keyword=N_ -o $(srcdir)/WebKit/gtk/po/$(DOMAIN).pot \
     87 	    ;; \
     88 	esac
     89 
     90 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
     91 # every "make" invocation, only create it when it is missing.
     92 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
     93 $(srcdir)/WebKit/gtk/po/$(DOMAIN).pot:
     94 	$(MAKE) $(DOMAIN).pot-update
     95 
     96 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
     97 # Note that a PO file is not touched if it doesn't need to be changed.
     98 $(POFILES): $(srcdir)/WebKit/gtk/po/$(DOMAIN).pot
     99 	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
    100 	if test -f "$(srcdir)/WebKit/gtk/po/$${lang}.po"; then \
    101 	  test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir)/WebKit/gtk/po && "; \
    102 	  echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
    103 	  cd $(srcdir)/WebKit/gtk/po && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
    104 	else \
    105 	  $(MAKE) $${lang}.po-create; \
    106 	fi
    107 
    108 update-po: GNUmakefile
    109 	$(MAKE) $(DOMAIN).pot-update
    110 	$(MAKE) $(POFILES)
    111 	$(MAKE) $(MOFILES)
    112 
    113 .nop.po-create:
    114 	@lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
    115 	echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
    116 	exit 1
    117 
    118 # clean rules
    119 CLEANFILES += \
    120 	$(top_builddir)/stamp-po
    121 
    122 MAINTAINERCLEANFILES += \
    123 	$(MOFILES)
    124 
    125 DISTCLEANFILES += \
    126 	$(MOFILES)
    127 
    128 po-install-data-local: all
    129 	$(mkdir_p) $(DESTDIR)$(datadir)
    130 	@catalogs='$(MOFILES)'; \
    131 	for cat in $$catalogs; do \
    132 	  cat=`basename $$cat`; \
    133 	  lang=`echo $$cat | sed -e 's/\.mo$$//'`; \
    134 	  dir=$(localedir)/$$lang/LC_MESSAGES; \
    135 	  $(mkdir_p) $(DESTDIR)$$dir; \
    136 	  if test -r WebKit/gtk/po/$$cat; then realcat=WebKit/gtk/po/$$cat; else realcat=$(srcdir)/$$cat; fi; \
    137 	  $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
    138 	  echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
    139 	  for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
    140 	    if test -n "$$lc"; then \
    141 	      if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
    142 	        link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
    143 	        mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
    144 	        mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
    145 	        (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
    146 	         for file in *; do \
    147 	           if test -f $$file; then \
    148 	             ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
    149 	           fi; \
    150 	         done); \
    151 	        rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
    152 	      else \
    153 	        if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
    154 	          :; \
    155 	        else \
    156 	          rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
    157 	          mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
    158 	        fi; \
    159 	      fi; \
    160 	      rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
    161 	      ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
    162 	      ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
    163 	      cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
    164 	      echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
    165 	    fi; \
    166 	  done; \
    167 	done
    168 
    169 po-installdirs-data-local:
    170 	$(mkdir_p) $(DESTDIR)$(datadir)
    171 	@catalogs='$(MOFILES)'; \
    172 	for cat in $$catalogs; do \
    173 	  cat=`basename $$cat`; \
    174 	  lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
    175 	  dir=$(localedir)/$$lang/LC_MESSAGES; \
    176 	  $(mkdir_p) $(DESTDIR)$$dir; \
    177 	  for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
    178 	    if test -n "$$lc"; then \
    179 	      if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
    180 	        link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
    181 	        mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
    182 	        mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
    183 	        (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
    184 	         for file in *; do \
    185 	           if test -f $$file; then \
    186 	             ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
    187 	           fi; \
    188 	         done); \
    189 	        rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
    190 	      else \
    191 	        if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
    192 	          :; \
    193 	        else \
    194 	          rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
    195 	          mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
    196 	        fi; \
    197 	      fi; \
    198 	    fi; \
    199 	  done; \
    200 	done
    201 
    202 po-uninstall-local:
    203 	catalogs='$(MOFILES)'; \
    204 	for cat in $$catalogs; do \
    205 	  cat=`basename $$cat`; \
    206 	  lang=`echo $$cat | sed -e 's/\.mo$$//'`; \
    207 	  for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
    208 	    rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
    209 	  done; \
    210 	done
    211