Commit | Line | Data |
---|---|---|
62ba5143 JH |
1 | # The default target of this Makefile is... |
2 | all:: | |
3 | ||
4 | prefix ?= $(HOME) | |
5 | bindir ?= $(prefix)/bin | |
f85fd3f0 JH |
6 | sharedir ?= $(prefix)/share |
7 | gitk_libdir ?= $(sharedir)/gitk/lib | |
8 | msgsdir ?= $(gitk_libdir)/msgs | |
9 | msgsdir_SQ = $(subst ','\'',$(msgsdir)) | |
10 | ||
4698ef55 | 11 | TCL_PATH ?= tclsh |
62ba5143 JH |
12 | TCLTK_PATH ?= wish |
13 | INSTALL ?= install | |
14 | RM ?= rm -f | |
15 | ||
16 | DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) | |
17 | bindir_SQ = $(subst ','\'',$(bindir)) | |
18 | TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH)) | |
19 | ||
9a6c84e6 JH |
20 | ### Detect Tck/Tk interpreter path changes |
21 | TRACK_TCLTK = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)') | |
22 | ||
23 | GIT-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 | ||
f85fd3f0 JH |
30 | ## po-file creation rules |
31 | XGETTEXT ?= xgettext | |
887ad798 JH |
32 | ifdef NO_MSGFMT |
33 | MSGFMT ?= $(TCL_PATH) po/po2msg.sh | |
34 | else | |
35 | MSGFMT ?= msgfmt | |
4698ef55 JH |
36 | ifneq ($(shell $(MSGFMT) --tcl -l C -d . /dev/null 2>/dev/null; echo $$?),0) |
37 | MSGFMT := $(TCL_PATH) po/po2msg.sh | |
38 | endif | |
887ad798 JH |
39 | endif |
40 | ||
f85fd3f0 JH |
41 | PO_TEMPLATE = po/gitk.pot |
42 | ALL_POFILES = $(wildcard po/*.po) | |
43 | ALL_MSGFILES = $(subst .po,.msg,$(ALL_POFILES)) | |
44 | ||
62ba5143 JH |
45 | ifndef V |
46 | QUIET = @ | |
47 | QUIET_GEN = $(QUIET)echo ' ' GEN $@ && | |
48 | endif | |
49 | ||
f85fd3f0 JH |
50 | all:: gitk-wish $(ALL_MSGFILES) |
51 | ||
62ba5143 | 52 | install:: all |
ffac48d0 | 53 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)' |
c7ea4536 JH |
54 | $(INSTALL) -m 755 gitk-wish '$(DESTDIR_SQ)$(bindir_SQ)'/gitk |
55 | $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(msgsdir_SQ)' | |
56 | $(foreach p,$(ALL_MSGFILES), $(INSTALL) -m 644 $p '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true | |
f85fd3f0 JH |
57 | |
58 | uninstall:: | |
59 | $(foreach p,$(ALL_MSGFILES), $(RM) '$(DESTDIR_SQ)$(msgsdir_SQ)'/$(notdir $p) &&) true | |
60 | $(RM) '$(DESTDIR_SQ)$(bindir_SQ)'/gitk | |
61 | ||
62ba5143 | 62 | clean:: |
9a6c84e6 | 63 | $(RM) gitk-wish po/*.msg GIT-TCLTK-VARS |
62ba5143 | 64 | |
9a6c84e6 | 65 | gitk-wish: gitk GIT-TCLTK-VARS |
62ba5143 JH |
66 | $(QUIET_GEN)$(RM) $@ $@+ && \ |
67 | sed -e '1,3s|^exec .* "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' <gitk >$@+ && \ | |
68 | chmod +x $@+ && \ | |
69 | mv -f $@+ $@ | |
f85fd3f0 JH |
70 | |
71 | $(PO_TEMPLATE): gitk | |
72 | $(XGETTEXT) -kmc -LTcl -o $@ gitk | |
73 | update-po:: $(PO_TEMPLATE) | |
74 | $(foreach p, $(ALL_POFILES), echo Updating $p ; msgmerge -U $p $(PO_TEMPLATE) ; ) | |
75 | $(ALL_MSGFILES): %.msg : %.po | |
76 | @echo Generating catalog $@ | |
77 | $(MSGFMT) --statistics --tcl $< -l $(basename $(notdir $<)) -d $(dir $@) | |
78 | ||
9a6c84e6 JH |
79 | .PHONY: all install uninstall clean update-po |
80 | .PHONY: FORCE |