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