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