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