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
11TCL_PATH ?= tclsh
12TCLTK_PATH ?= wish
13INSTALL ?= install
14RM ?= rm -f
15
16DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
17bindir_SQ = $(subst ','\'',$(bindir))
18TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
19
20### Detect Tck/Tk interpreter path changes
21TRACK_TCLTK = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
22
23GIT-TCLTK-VARS: FORCE
24 @VARS='$(TRACK_TCLTK)'; \
25 if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
26 echo 1>&2 " * new Tcl/Tk interpreter location"; \
27 echo "$$VARS" >$@; \
28 fi
29
30## po-file creation rules
31XGETTEXT ?= xgettext
32ifdef NO_MSGFMT
33 MSGFMT ?= $(TCL_PATH) po/po2msg.sh
34else
35 MSGFMT ?= msgfmt
36 ifneq ($(shell $(MSGFMT) --tcl -l C -d . /dev/null 2>/dev/null; echo $$?),0)
37 MSGFMT := $(TCL_PATH) po/po2msg.sh
38 endif
39endif
40
41PO_TEMPLATE = po/gitk.pot
42ALL_POFILES = $(wildcard po/*.po)
43ALL_MSGFILES = $(subst .po,.msg,$(ALL_POFILES))
44
45ifndef V
46 QUIET = @
47 QUIET_GEN = $(QUIET)echo ' ' GEN $@ &&
48endif
49
50all:: gitk-wish $(ALL_MSGFILES)
51
52install:: all
53 $(INSTALL) -m 755 gitk-wish '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
54 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(msgsdir_SQ)'
55 $(foreach p,$(ALL_MSGFILES), $(INSTALL) -m 644 $p '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
56
57uninstall::
58 $(foreach p,$(ALL_MSGFILES), $(RM) '$(DESTDIR_SQ)$(msgsdir_SQ)'/$(notdir $p) &&) true
59 $(RM) '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
60
61clean::
62 $(RM) gitk-wish po/*.msg GIT-TCLTK-VARS
63
64gitk-wish: gitk GIT-TCLTK-VARS
65 $(QUIET_GEN)$(RM) $@ $@+ && \
66 sed -e '1,3s|^exec .* "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' <gitk >$@+ && \
67 chmod +x $@+ && \
68 mv -f $@+ $@
69
70$(PO_TEMPLATE): gitk
71 $(XGETTEXT) -kmc -LTcl -o $@ gitk
72update-po:: $(PO_TEMPLATE)
73 $(foreach p, $(ALL_POFILES), echo Updating $p ; msgmerge -U $p $(PO_TEMPLATE) ; )
74$(ALL_MSGFILES): %.msg : %.po
75 @echo Generating catalog $@
76 $(MSGFMT) --statistics --tcl $< -l $(basename $(notdir $<)) -d $(dir $@)
77
78.PHONY: all install uninstall clean update-po
79.PHONY: FORCE