blob: 5bdd52a6ebfa722fe077ec6a3160f9bbd8ff6a2b [file] [log] [blame]
Junio C Hamano62ba5142007-11-17 10:51:16 -08001# The default target of this Makefile is...
2all::
3
4prefix ?= $(HOME)
5bindir ?= $(prefix)/bin
Junio C Hamanof85fd3f2008-01-08 22:41:15 -08006sharedir ?= $(prefix)/share
7gitk_libdir ?= $(sharedir)/gitk/lib
8msgsdir ?= $(gitk_libdir)/msgs
9msgsdir_SQ = $(subst ','\'',$(msgsdir))
10
Junio C Hamano4698ef52008-03-14 17:49:40 -070011TCL_PATH ?= tclsh
Junio C Hamano62ba5142007-11-17 10:51:16 -080012TCLTK_PATH ?= wish
13INSTALL ?= install
14RM ?= rm -f
15
16DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
17bindir_SQ = $(subst ','\'',$(bindir))
18TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
19
Junio C Hamano9a6c84e2013-01-30 13:52:44 -080020### 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
Junio C Hamanof85fd3f2008-01-08 22:41:15 -080030## po-file creation rules
31XGETTEXT ?= xgettext
Junio C Hamano887ad792008-01-11 00:51:30 -080032ifdef NO_MSGFMT
33 MSGFMT ?= $(TCL_PATH) po/po2msg.sh
34else
35 MSGFMT ?= msgfmt
Junio C Hamano4698ef52008-03-14 17:49:40 -070036 ifneq ($(shell $(MSGFMT) --tcl -l C -d . /dev/null 2>/dev/null; echo $$?),0)
37 MSGFMT := $(TCL_PATH) po/po2msg.sh
38 endif
Junio C Hamano887ad792008-01-11 00:51:30 -080039endif
40
Junio C Hamanof85fd3f2008-01-08 22:41:15 -080041PO_TEMPLATE = po/gitk.pot
42ALL_POFILES = $(wildcard po/*.po)
43ALL_MSGFILES = $(subst .po,.msg,$(ALL_POFILES))
44
Junio C Hamano62ba5142007-11-17 10:51:16 -080045ifndef V
46 QUIET = @
47 QUIET_GEN = $(QUIET)echo ' ' GEN $@ &&
48endif
49
Junio C Hamanof85fd3f2008-01-08 22:41:15 -080050all:: gitk-wish $(ALL_MSGFILES)
51
Junio C Hamano62ba5142007-11-17 10:51:16 -080052install:: all
Junio C Hamanoffac48d2017-01-18 10:27:59 -080053 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
Junio C Hamanoc7ea4532008-05-14 21:27:55 -070054 $(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
Junio C Hamanof85fd3f2008-01-08 22:41:15 -080057
58uninstall::
59 $(foreach p,$(ALL_MSGFILES), $(RM) '$(DESTDIR_SQ)$(msgsdir_SQ)'/$(notdir $p) &&) true
60 $(RM) '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
61
Junio C Hamano62ba5142007-11-17 10:51:16 -080062clean::
Junio C Hamano9a6c84e2013-01-30 13:52:44 -080063 $(RM) gitk-wish po/*.msg GIT-TCLTK-VARS
Junio C Hamano62ba5142007-11-17 10:51:16 -080064
Junio C Hamano9a6c84e2013-01-30 13:52:44 -080065gitk-wish: gitk GIT-TCLTK-VARS
Junio C Hamano62ba5142007-11-17 10:51:16 -080066 $(QUIET_GEN)$(RM) $@ $@+ && \
67 sed -e '1,3s|^exec .* "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' <gitk >$@+ && \
68 chmod +x $@+ && \
69 mv -f $@+ $@
Junio C Hamanof85fd3f2008-01-08 22:41:15 -080070
71$(PO_TEMPLATE): gitk
72 $(XGETTEXT) -kmc -LTcl -o $@ gitk
73update-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
Junio C Hamano9a6c84e2013-01-30 13:52:44 -080079.PHONY: all install uninstall clean update-po
80.PHONY: FORCE