3 # Define V=1 to have a more verbose compile.
6 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
7 @$(SHELL_PATH) ./GIT-VERSION-GEN
8 -include GIT-VERSION-FILE
10 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
12 SCRIPT_SH = git-gui.sh
13 GITGUI_BUILT_INS = git-citool
14 ALL_PROGRAMS = $(GITGUI_BUILT_INS) $(patsubst %.sh,%,$(SCRIPT_SH))
15 ALL_LIBFILES = $(wildcard lib/*.tcl)
16 PRELOAD_FILES = lib/class.tcl
23 gitexecdir := $(shell git --exec-path)
27 sharedir := $(dir $(gitexecdir))share
35 QUIET_GEN = @echo ' ' GEN $@;
36 QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
37 QUIET_INDEX = @echo ' ' INDEX $(dir $@);
38 QUIET_2DEVNULL = 2>/dev/null
44 ifeq ($(findstring $(MAKEFLAGS),s),s)
49 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
50 gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
51 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
52 TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH))
53 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
55 libdir ?= $(sharedir)/git-gui/lib
56 libdir_SQ = $(subst ','\'',$(libdir))
58 exedir = $(dir $(gitexecdir))share/git-gui/lib
59 exedir_SQ = $(subst ','\'',$(exedir))
61 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
62 $(QUIET_GEN)rm -f $@ $@+ && \
64 if test '$(exedir_SQ)' = '$(libdir_SQ)'; then \
65 if test "$(uname_O)" = Cygwin; \
66 then GITGUI_RELATIVE= ; \
67 else GITGUI_RELATIVE=1; \
70 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
71 -e 's|^ exec wish "$$0"| exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \
72 -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
73 -e 's|@@GITGUI_RELATIVE@@|'$$GITGUI_RELATIVE'|' \
74 -e $$GITGUI_RELATIVE's|@@GITGUI_LIBDIR@@|$(libdir_SQ)|' \
79 $(GITGUI_BUILT_INS): git-gui
80 $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@
82 lib/tclIndex: $(ALL_LIBFILES)
83 $(QUIET_INDEX)if echo \
84 $(foreach p,$(PRELOAD_FILES),source $p\;) \
85 auto_mkindex lib '*.tcl' \
86 | $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \
88 echo 1>&2 " * $(TCL_PATH) failed; using unoptimized loading"; \
90 echo '# Autogenerated by git-gui Makefile' >$@ && \
92 $(foreach p,$(PRELOAD_FILES) $(ALL_LIBFILES),echo '$(subst lib/,,$p)' >>$@ &&) \
96 # These can record GITGUI_VERSION
97 $(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE GIT-GUI-VARS
98 lib/tclIndex: GIT-GUI-VARS
101 $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
102 $(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
103 $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
104 $(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
105 $(subst ','\'',libdir='$(libdir_SQ)') \
108 GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
109 @VARS='$(TRACK_VARS)'; \
110 if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
111 echo 1>&2 " * new locations or Tcl/Tk interpreter"; \
112 echo 1>$@ "$$VARS"; \
115 all:: $(ALL_PROGRAMS) lib/tclIndex
118 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
119 $(INSTALL) git-gui '$(DESTDIR_SQ)$(gitexecdir_SQ)'
120 $(foreach p,$(GITGUI_BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
121 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(libdir_SQ)'
122 $(INSTALL) -m644 lib/tclIndex '$(DESTDIR_SQ)$(libdir_SQ)'
123 $(foreach p,$(ALL_LIBFILES), $(INSTALL) -m644 $p '$(DESTDIR_SQ)$(libdir_SQ)' ;)
127 @echo $(GITGUI_VERSION) > $(TARDIR)/version
130 rm -f $(ALL_PROGRAMS) lib/tclIndex
131 rm -f GIT-VERSION-FILE GIT-GUI-VARS
133 .PHONY: all install dist-version clean
134 .PHONY: .FORCE-GIT-VERSION-FILE
135 .PHONY: .FORCE-GIT-GUI-VARS