61585045b765287a11c88987413c002f5596f908
   1# The default target of this Makefile is...
   2all::
   3
   4prefix ?= $(HOME)
   5bindir ?= $(prefix)/bin
   6sharedir ?= $(prefix)/share
   7gitk_libdir   ?= $(sharedir)/gitk/lib
   8msgsdir    ?= $(gitk_libdir)/msgs
   9msgsdir_SQ  = $(subst ','\'',$(msgsdir))
  10
  11TCLTK_PATH ?= wish
  12INSTALL ?= install
  13RM ?= rm -f
  14
  15DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  16bindir_SQ = $(subst ','\'',$(bindir))
  17TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
  18
  19## po-file creation rules
  20XGETTEXT   ?= xgettext
  21MSGFMT     ?= msgfmt
  22PO_TEMPLATE = po/gitk.pot
  23ALL_POFILES = $(wildcard po/*.po)
  24ALL_MSGFILES = $(subst .po,.msg,$(ALL_POFILES))
  25
  26ifndef V
  27        QUIET          = @
  28        QUIET_GEN      = $(QUIET)echo '   ' GEN $@ &&
  29endif
  30
  31all:: gitk-wish $(ALL_MSGFILES)
  32
  33install:: all
  34        $(INSTALL) gitk-wish '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
  35        $(INSTALL) -d '$(DESTDIR_SQ)$(msgsdir_SQ)'
  36        $(foreach p,$(ALL_MSGFILES), $(INSTALL) $p '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
  37
  38uninstall::
  39        $(foreach p,$(ALL_MSGFILES), $(RM) '$(DESTDIR_SQ)$(msgsdir_SQ)'/$(notdir $p) &&) true
  40        $(RM) '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
  41
  42clean::
  43        $(RM) gitk-wish po/*.msg
  44
  45gitk-wish: gitk
  46        $(QUIET_GEN)$(RM) $@ $@+ && \
  47        sed -e '1,3s|^exec .* "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' <gitk >$@+ && \
  48        chmod +x $@+ && \
  49        mv -f $@+ $@
  50
  51$(PO_TEMPLATE): gitk
  52        $(XGETTEXT) -kmc -LTcl -o $@ gitk
  53update-po:: $(PO_TEMPLATE)
  54        $(foreach p, $(ALL_POFILES), echo Updating $p ; msgmerge -U $p $(PO_TEMPLATE) ; )
  55$(ALL_MSGFILES): %.msg : %.po
  56        @echo Generating catalog $@
  57        $(MSGFMT) --statistics --tcl $< -l $(basename $(notdir $<)) -d $(dir $@)
  58