gitweb: fix another use of undefined value
[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
3ed02de2 10SCRIPT_SH = git-gui.sh
b4d2b04c 11GITGUI_BUILT_INS = git-citool
3ed02de2 12ALL_PROGRAMS = $(GITGUI_BUILT_INS) $(patsubst %.sh,%,$(SCRIPT_SH))
5f5dbd71 13ALL_LIBFILES = $(wildcard lib/*.tcl)
b4d2b04c
JH
14
15ifndef SHELL_PATH
16 SHELL_PATH = /bin/sh
17endif
18
67c75759
JH
19ifndef gitexecdir
20 gitexecdir := $(shell git --exec-path)
21endif
22
5f5dbd71
SP
23ifndef sharedir
24 sharedir := $(dir $(gitexecdir))/share
25endif
26
67c75759
JH
27ifndef INSTALL
28 INSTALL = install
29endif
b4d2b04c 30
eec10252
JH
31ifndef V
32 QUIET_GEN = @echo ' ' GEN $@;
33 QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
5f5dbd71 34 QUIET_INDEX = @echo ' ' INDEX $(dir $@);
eec10252
JH
35endif
36
5f5dbd71 37TCL_PATH ?= tclsh
c182ec90
JH
38TCLTK_PATH ?= wish
39
27ebd6e0
JH
40ifeq ($(findstring $(MAKEFLAGS),s),s)
41QUIET_GEN =
42QUIET_BUILT_IN =
43endif
44
b4d2b04c
JH
45DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
46gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
b4d2b04c 47SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
c182ec90 48TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
b4d2b04c 49
5f5dbd71
SP
50libdir ?= $(sharedir)/git-gui/lib
51libdir_SQ = $(subst ','\'',$(libdir))
52
3ed02de2 53$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
eec10252 54 $(QUIET_GEN)rm -f $@ $@+ && \
3ed02de2 55 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
c182ec90 56 -e 's|^exec wish "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \
67c75759 57 -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
5f5dbd71 58 -e 's|@@GITGUI_LIBDIR@@|$(libdir_SQ)|' \
eec10252 59 $@.sh >$@+ && \
eec10252 60 chmod +x $@+ && \
b4d2b04c
JH
61 mv $@+ $@
62
63$(GITGUI_BUILT_INS): git-gui
eec10252 64 $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@
b4d2b04c 65
5f5dbd71 66lib/tclIndex: $(ALL_LIBFILES)
2b93bfac
JH
67 $(QUIET_INDEX)echo \
68 source lib/class.tcl \; \
69 auto_mkindex lib '*.tcl' \
70 | $(TCL_PATH)
5f5dbd71 71
3ed02de2 72# These can record GITGUI_VERSION
5f5dbd71
SP
73$(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE GIT-GUI-VARS
74
75TRACK_VARS = \
76 $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
77 $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
78 $(subst ','\'',libdir='$(libdir_SQ)') \
79#end TRACK_VARS
80
81GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
82 @VARS='$(TRACK_VARS)'; \
83 if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
84 echo 1>&2 " * new locations or Tcl/Tk interpreter"; \
85 echo 1>$@ "$$VARS"; \
86 fi
3ed02de2 87
5f5dbd71 88all:: $(ALL_PROGRAMS) lib/tclIndex
b4d2b04c
JH
89
90install: all
91 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
92 $(INSTALL) git-gui '$(DESTDIR_SQ)$(gitexecdir_SQ)'
93 $(foreach p,$(GITGUI_BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
5f5dbd71
SP
94 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(libdir_SQ)'
95 $(INSTALL) -m644 lib/tclIndex '$(DESTDIR_SQ)$(libdir_SQ)'
96 $(foreach p,$(ALL_LIBFILES), $(INSTALL) -m644 $p '$(DESTDIR_SQ)$(libdir_SQ)' ;)
b4d2b04c 97
3ed02de2 98dist-version:
67c75759
JH
99 @mkdir -p $(TARDIR)
100 @echo $(GITGUI_VERSION) > $(TARDIR)/version
101
b4d2b04c 102clean::
5f5dbd71
SP
103 rm -f $(ALL_PROGRAMS) lib/tclIndex
104 rm -f GIT-VERSION-FILE GIT-GUI-VARS
b4d2b04c 105
67c75759 106.PHONY: all install dist-version clean
b4d2b04c 107.PHONY: .FORCE-GIT-VERSION-FILE
5f5dbd71 108.PHONY: .FORCE-GIT-GUI-VARS