Testing tangled. Original: https://github.com/j6t/gitk
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
11SHELL_PATH ?= /bin/sh
12TCL_PATH ?= tclsh
13TCLTK_PATH ?= wish
14INSTALL ?= install
15RM ?= rm -f
16
17DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
18bindir_SQ = $(subst ','\'',$(bindir))
19TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
20
21### Detect Tck/Tk interpreter path changes
22TRACK_TCLTK = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
23
24GIT-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
32XGETTEXT ?= xgettext
33ifdef NO_MSGFMT
34 MSGFMT ?= $(TCL_PATH) po/po2msg.sh
35else
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
40endif
41
42PO_TEMPLATE = po/gitk.pot
43ALL_POFILES = $(wildcard po/*.po)
44ALL_MSGFILES = $(subst .po,.msg,$(ALL_POFILES))
45
46ifndef V
47 QUIET = @
48 QUIET_GEN = $(QUIET)echo ' ' GEN $@ &&
49endif
50
51all:: gitk-wish $(ALL_MSGFILES)
52
53install:: 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
59uninstall::
60 $(foreach p,$(ALL_MSGFILES), $(RM) '$(DESTDIR_SQ)$(msgsdir_SQ)'/$(notdir $p) &&) true
61 $(RM) '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
62
63clean::
64 $(RM) gitk-wish po/*.msg GIT-TCLTK-VARS
65
66gitk-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 -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