| 1 | # The default target of this Makefile is... |
| 2 | all:: |
| 3 | |
| 4 | prefix ?= $(HOME) |
| 5 | bindir ?= $(prefix)/bin |
| 6 | sharedir ?= $(prefix)/share |
| 7 | gitk_libdir ?= $(sharedir)/gitk/lib |
| 8 | msgsdir ?= $(gitk_libdir)/msgs |
| 9 | msgsdir_SQ = $(subst ','\'',$(msgsdir)) |
| 10 | |
| 11 | SHELL_PATH ?= /bin/sh |
| 12 | TCL_PATH ?= tclsh |
| 13 | TCLTK_PATH ?= wish |
| 14 | INSTALL ?= install |
| 15 | RM ?= rm -f |
| 16 | |
| 17 | DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) |
| 18 | bindir_SQ = $(subst ','\'',$(bindir)) |
| 19 | TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH)) |
| 20 | |
| 21 | ### Detect Tck/Tk interpreter path changes |
| 22 | TRACK_TCLTK = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)') |
| 23 | |
| 24 | GIT-TCLTK-VARS: FORCE |
| 25 | @VARS='$(TRACK_TCLTK)'; \ |
| 26 | if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \ |
| 27 | echo 1>&2 " * new Tcl/Tk interpreter location"; \ |
| 28 | echo "$$VARS" >$@; \ |
| 29 | fi |
| 30 | |
| 31 | ## po-file creation rules |
| 32 | XGETTEXT ?= xgettext |
| 33 | ifdef NO_MSGFMT |
| 34 | MSGFMT ?= $(TCL_PATH) po/po2msg.sh |
| 35 | else |
| 36 | MSGFMT ?= msgfmt |
| 37 | ifneq ($(shell $(MSGFMT) --tcl -l C -d . /dev/null 2>/dev/null; echo $$?),0) |
| 38 | MSGFMT := $(TCL_PATH) po/po2msg.sh |
| 39 | endif |
| 40 | endif |
| 41 | |
| 42 | PO_TEMPLATE = po/gitk.pot |
| 43 | ALL_POFILES = $(wildcard po/*.po) |
| 44 | ALL_MSGFILES = $(subst .po,.msg,$(ALL_POFILES)) |
| 45 | |
| 46 | ifneq ($(findstring s,$(firstword -$(MAKEFLAGS))),s) |
| 47 | ifndef V |
| 48 | QUIET = @ |
| 49 | QUIET_GEN = $(QUIET)echo ' ' GEN $@ && |
| 50 | QUIET_MSGFMT = $(QUIET)echo ' ' MSGFMT $@ && |
| 51 | endif |
| 52 | endif |
| 53 | |
| 54 | all:: gitk-wish $(ALL_MSGFILES) |
| 55 | |
| 56 | install:: all |
| 57 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)' |
| 58 | $(INSTALL) -m 755 gitk-wish '$(DESTDIR_SQ)$(bindir_SQ)'/gitk |
| 59 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(msgsdir_SQ)' |
| 60 | $(foreach p,$(ALL_MSGFILES), $(INSTALL) -m 644 $p '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true |
| 61 | |
| 62 | uninstall:: |
| 63 | $(foreach p,$(ALL_MSGFILES), $(RM) '$(DESTDIR_SQ)$(msgsdir_SQ)'/$(notdir $p) &&) true |
| 64 | $(RM) '$(DESTDIR_SQ)$(bindir_SQ)'/gitk |
| 65 | |
| 66 | clean:: |
| 67 | $(RM) gitk-wish po/*.msg GIT-TCLTK-VARS |
| 68 | |
| 69 | gitk-wish: gitk GIT-TCLTK-VARS |
| 70 | $(QUIET_GEN)$(RM) $@ $@+ && \ |
| 71 | $(SHELL_PATH) ./generate-tcl.sh "$(TCLTK_PATH_SQ)" "$<" "$@" |
| 72 | |
| 73 | $(PO_TEMPLATE): gitk |
| 74 | $(XGETTEXT) -kmc -LTcl --package-name=Gitk -o $@ gitk |
| 75 | update-po:: $(PO_TEMPLATE) |
| 76 | $(foreach p, $(ALL_POFILES), echo Updating $p ; msgmerge -U --add-location $p $(PO_TEMPLATE) ; ) |
| 77 | @echo "Before committing changes, ensure that a clean-filter is installed:"; \ |
| 78 | echo; \ |
| 79 | echo " git config filter.gettext-no-location.clean \"msgcat --no-location -\"" |
| 80 | $(ALL_MSGFILES): %.msg : %.po |
| 81 | $(QUIET_MSGFMT)$(MSGFMT) --tcl -l $(basename $(notdir $<)) -d $(dir $@) $< |
| 82 | |
| 83 | .PHONY: all install uninstall clean update-po |
| 84 | .PHONY: FORCE |