Raw
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 ifndef V
47 QUIET = @
48 QUIET_GEN = $(QUIET)echo ' ' GEN $@ &&
49 endif
50
51 all:: gitk-wish $(ALL_MSGFILES)
52
53 install:: all
54 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
55 $(INSTALL) -m 755 gitk-wish '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
56 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(msgsdir_SQ)'
57 $(foreach p,$(ALL_MSGFILES), $(INSTALL) -m 644 $p '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
58
59 uninstall::
60 $(foreach p,$(ALL_MSGFILES), $(RM) '$(DESTDIR_SQ)$(msgsdir_SQ)'/$(notdir $p) &&) true
61 $(RM) '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
62
63 clean::
64 $(RM) gitk-wish po/*.msg GIT-TCLTK-VARS
65
66 gitk-wish: gitk GIT-TCLTK-VARS
67 $(QUIET_GEN)$(RM) $@ $@+ && \
68 $(SHELL_PATH) ./generate-tcl.sh "$(TCLTK_PATH_SQ)" "$<" "$@"
69
70 $(PO_TEMPLATE): gitk
71 $(XGETTEXT) -kmc -LTcl --package-name=Gitk -o $@ gitk
72 update-po:: $(PO_TEMPLATE)
73 $(foreach p, $(ALL_POFILES), echo Updating $p ; msgmerge -U --add-location $p $(PO_TEMPLATE) ; )
74 @echo "Before committing changes, ensure that a clean-filter is installed:"; \
75 echo; \
76 echo " git config filter.gettext-no-location.clean \"msgcat --no-location -\""
77 $(ALL_MSGFILES): %.msg : %.po
78 @echo Generating catalog $@
79 $(MSGFMT) --statistics --tcl -l $(basename $(notdir $<)) -d $(dir $@) $<
80
81 .PHONY: all install uninstall clean update-po
82 .PHONY: FORCE