1all::
2
3# Define V=1 to have a more verbose compile.
4#
5QUIET =
6QUIET_MSG = :
7ifndef V
8 QUIET = @
9 QUIET_MSG = echo ' '
10endif
11
12GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
13 @$(SHELL_PATH) ./GIT-VERSION-GEN
14-include GIT-VERSION-FILE
15
16SCRIPT_SH = git-gui.sh
17GITGUI_BUILT_INS = git-citool
18ALL_PROGRAMS = $(GITGUI_BUILT_INS) $(patsubst %.sh,%,$(SCRIPT_SH))
19ALL_LIBFILES = $(wildcard lib/*.tcl)
20PRELOAD_FILES = lib/class.tcl
21
22ifndef SHELL_PATH
23 SHELL_PATH = /bin/sh
24endif
25
26ifndef gitexecdir
27 gitexecdir := $(shell git --exec-path)
28endif
29
30ifndef sharedir
31 sharedir := $(dir $(gitexecdir))share
32endif
33
34ifndef INSTALL
35 INSTALL = install
36endif
37
38ifndef V
39 QUIET_GEN = @echo ' ' GEN $@;
40 QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
41 QUIET_INDEX = @echo ' ' INDEX $(dir $@);
42 QUIET_2DEVNULL = 2>/dev/null
43endif
44
45TCL_PATH ?= tclsh
46TCLTK_PATH ?= wish
47
48ifeq ($(findstring $(MAKEFLAGS),s),s)
49QUIET_GEN =
50QUIET_BUILT_IN =
51endif
52
53DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
54gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
55SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
56TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH))
57TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
58
59libdir ?= $(sharedir)/git-gui/lib
60libdir_SQ = $(subst ','\'',$(libdir))
61
62exedir = $(dir $(gitexecdir))share/git-gui/lib
63exedir_SQ = $(subst ','\'',$(exedir))
64
65$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
66 $(QUIET_GEN)rm -f $@ $@+ && \
67 if test '$(exedir_SQ)' = '$(libdir_SQ)'; then \
68 GITGUI_RELATIVE=1; \
69 fi && \
70 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
71 -e 's|^exec wish "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \
72 -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
73 -e 's|@@GITGUI_RELATIVE@@|'$$GITGUI_RELATIVE'|' \
74 -e $$GITGUI_RELATIVE's|@@GITGUI_LIBDIR@@|$(libdir_SQ)|' \
75 $@.sh >$@+ && \
76 chmod +x $@+ && \
77 mv $@+ $@
78
79$(GITGUI_BUILT_INS): git-gui
80 $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@
81
82lib/tclIndex: $(ALL_LIBFILES)
83 $(QUIET_INDEX)if echo \
84 $(foreach p,$(PRELOAD_FILES),source $p\;) \
85 auto_mkindex lib '*.tcl' \
86 | $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \
87 else \
88 echo 1>&2 " * $(TCL_PATH) failed; using unoptimized loading"; \
89 rm -f $@ ; \
90 echo '# Autogenerated by git-gui Makefile' >$@ && \
91 echo >>$@ && \
92 $(foreach p,$(PRELOAD_FILES) $(ALL_LIBFILES),echo '$(subst lib/,,$p)' >>$@ &&) \
93 echo >>$@ ; \
94 fi
95
96# These can record GITGUI_VERSION
97$(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE GIT-GUI-VARS
98lib/tclIndex: GIT-GUI-VARS
99
100TRACK_VARS = \
101 $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
102 $(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
103 $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
104 $(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
105 $(subst ','\'',libdir='$(libdir_SQ)') \
106#end TRACK_VARS
107
108GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
109 @VARS='$(TRACK_VARS)'; \
110 if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
111 echo 1>&2 " * new locations or Tcl/Tk interpreter"; \
112 echo 1>$@ "$$VARS"; \
113 fi
114
115all:: $(ALL_PROGRAMS) lib/tclIndex
116
117install: all
118 $(QUIET)$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
119 $(QUIET)$(QUIET_MSG)INSTALL git-gui; $(INSTALL) git-gui '$(DESTDIR_SQ)$(gitexecdir_SQ)'
120 $(QUIET)$(foreach p,$(GITGUI_BUILT_INS),$(QUIET_MSG)INSTALL $p;\
121 rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && \
122 ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
123 $(QUIET)$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(libdir_SQ)'
124 $(QUIET)$(foreach p,lib/tclIndex $(ALL_LIBFILES), $(QUIET_MSG)INSTALL $p;\
125 $(INSTALL) -m644 $p '$(DESTDIR_SQ)$(libdir_SQ)' ;)
126
127dist-version:
128 @mkdir -p $(TARDIR)
129 @echo $(GITGUI_VERSION) > $(TARDIR)/version
130
131clean::
132 rm -f $(ALL_PROGRAMS) lib/tclIndex
133 rm -f GIT-VERSION-FILE GIT-GUI-VARS
134
135.PHONY: all install dist-version clean
136.PHONY: .FORCE-GIT-VERSION-FILE
137.PHONY: .FORCE-GIT-GUI-VARS