Merge branch 'maint'
[git/git.git] / Makefile
CommitLineData
41bdcda3
SP
1all::
2
0b5ea163
SP
3# Define V=1 to have a more verbose compile.
4#
5
f1cee4e6
SP
6GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
7 @$(SHELL_PATH) ./GIT-VERSION-GEN
8-include GIT-VERSION-FILE
9
bb616ddd 10SCRIPT_SH = git-gui.sh
41bdcda3 11GITGUI_BUILT_INS = git-citool
bb616ddd 12ALL_PROGRAMS = $(GITGUI_BUILT_INS) $(patsubst %.sh,%,$(SCRIPT_SH))
f522c9b5 13ALL_LIBFILES = $(wildcard lib/*.tcl)
b9e7efb8 14PRELOAD_FILES = lib/class.tcl
41bdcda3
SP
15
16ifndef SHELL_PATH
17 SHELL_PATH = /bin/sh
18endif
b3678bac 19
663e7cf8
SP
20ifndef gitexecdir
21 gitexecdir := $(shell git --exec-path)
22endif
23
f522c9b5 24ifndef sharedir
ea75ee35 25 sharedir := $(dir $(gitexecdir))share
f522c9b5
SP
26endif
27
663e7cf8
SP
28ifndef INSTALL
29 INSTALL = install
30endif
b3678bac 31
0b5ea163
SP
32ifndef V
33 QUIET_GEN = @echo ' ' GEN $@;
34 QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
f522c9b5 35 QUIET_INDEX = @echo ' ' INDEX $(dir $@);
b9e7efb8 36 QUIET_2DEVNULL = 2>/dev/null
0b5ea163
SP
37endif
38
f522c9b5 39TCL_PATH ?= tclsh
845d377b
JH
40TCLTK_PATH ?= wish
41
0c3b4aac
AR
42ifeq ($(findstring $(MAKEFLAGS),s),s)
43QUIET_GEN =
44QUIET_BUILT_IN =
45endif
46
b3678bac
SP
47DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
48gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
41bdcda3 49SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
b9e7efb8 50TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH))
845d377b 51TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
41bdcda3 52
f522c9b5
SP
53libdir ?= $(sharedir)/git-gui/lib
54libdir_SQ = $(subst ','\'',$(libdir))
55
ea75ee35
SP
56exedir = $(dir $(gitexecdir))share/git-gui/lib
57exedir_SQ = $(subst ','\'',$(exedir))
58
bb616ddd 59$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
0b5ea163 60 $(QUIET_GEN)rm -f $@ $@+ && \
ea75ee35
SP
61 if test '$(exedir_SQ)' = '$(libdir_SQ)'; then \
62 GITGUI_RELATIVE=1; \
63 fi && \
bb616ddd 64 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
845d377b 65 -e 's|^exec wish "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \
7e81d4ee 66 -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
ea75ee35
SP
67 -e 's|@@GITGUI_RELATIVE@@|'$$GITGUI_RELATIVE'|' \
68 -e $$GITGUI_RELATIVE's|@@GITGUI_LIBDIR@@|$(libdir_SQ)|' \
0b5ea163 69 $@.sh >$@+ && \
0b5ea163 70 chmod +x $@+ && \
41bdcda3
SP
71 mv $@+ $@
72
73$(GITGUI_BUILT_INS): git-gui
0b5ea163 74 $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@
41bdcda3 75
f522c9b5 76lib/tclIndex: $(ALL_LIBFILES)
b9e7efb8
SP
77 $(QUIET_INDEX)if echo \
78 $(foreach p,$(PRELOAD_FILES),source $p\;) \
1f07c4e5 79 auto_mkindex lib '*.tcl' \
b9e7efb8
SP
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
f522c9b5 89
bb616ddd 90# These can record GITGUI_VERSION
c6a5e403 91$(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE GIT-GUI-VARS
b9e7efb8 92lib/tclIndex: GIT-GUI-VARS
c6a5e403
SP
93
94TRACK_VARS = \
95 $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
b9e7efb8 96 $(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
c6a5e403 97 $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
ea75ee35 98 $(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
f522c9b5 99 $(subst ','\'',libdir='$(libdir_SQ)') \
c6a5e403
SP
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
bb616ddd 108
f522c9b5 109all:: $(ALL_PROGRAMS) lib/tclIndex
b3678bac
SP
110
111install: all
cb8773d1
SP
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' ;)
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)' ;)
41bdcda3 118
bb616ddd 119dist-version:
5d643cd3
SP
120 @mkdir -p $(TARDIR)
121 @echo $(GITGUI_VERSION) > $(TARDIR)/version
122
41bdcda3 123clean::
f522c9b5
SP
124 rm -f $(ALL_PROGRAMS) lib/tclIndex
125 rm -f GIT-VERSION-FILE GIT-GUI-VARS
f1cee4e6 126
5d643cd3 127.PHONY: all install dist-version clean
f1cee4e6 128.PHONY: .FORCE-GIT-VERSION-FILE
c6a5e403 129.PHONY: .FORCE-GIT-GUI-VARS