git-gui: Track our own embedded values and rebuild when they change
[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))
41bdcda3
SP
13
14ifndef SHELL_PATH
15 SHELL_PATH = /bin/sh
16endif
b3678bac 17
663e7cf8
SP
18ifndef gitexecdir
19 gitexecdir := $(shell git --exec-path)
20endif
21
22ifndef INSTALL
23 INSTALL = install
24endif
b3678bac 25
0b5ea163
SP
26ifndef V
27 QUIET_GEN = @echo ' ' GEN $@;
28 QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
29endif
30
845d377b
JH
31TCLTK_PATH ?= wish
32
0c3b4aac
AR
33ifeq ($(findstring $(MAKEFLAGS),s),s)
34QUIET_GEN =
35QUIET_BUILT_IN =
36endif
37
b3678bac
SP
38DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
39gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
41bdcda3 40SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
845d377b 41TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
41bdcda3 42
bb616ddd 43$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
0b5ea163 44 $(QUIET_GEN)rm -f $@ $@+ && \
bb616ddd 45 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
845d377b 46 -e 's|^exec wish "$$0"|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \
7e81d4ee 47 -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
0b5ea163 48 $@.sh >$@+ && \
0b5ea163 49 chmod +x $@+ && \
41bdcda3
SP
50 mv $@+ $@
51
52$(GITGUI_BUILT_INS): git-gui
0b5ea163 53 $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@
41bdcda3 54
bb616ddd 55# These can record GITGUI_VERSION
c6a5e403
SP
56$(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE GIT-GUI-VARS
57
58TRACK_VARS = \
59 $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
60 $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
61#end TRACK_VARS
62
63GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
64 @VARS='$(TRACK_VARS)'; \
65 if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
66 echo 1>&2 " * new locations or Tcl/Tk interpreter"; \
67 echo 1>$@ "$$VARS"; \
68 fi
bb616ddd 69
41bdcda3 70all:: $(ALL_PROGRAMS)
b3678bac
SP
71
72install: all
73 $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
74 $(INSTALL) git-gui '$(DESTDIR_SQ)$(gitexecdir_SQ)'
41bdcda3
SP
75 $(foreach p,$(GITGUI_BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
76
bb616ddd 77dist-version:
5d643cd3
SP
78 @mkdir -p $(TARDIR)
79 @echo $(GITGUI_VERSION) > $(TARDIR)/version
80
41bdcda3 81clean::
c6a5e403 82 rm -f $(ALL_PROGRAMS) GIT-VERSION-FILE GIT-GUI-VARS
f1cee4e6 83
5d643cd3 84.PHONY: all install dist-version clean
f1cee4e6 85.PHONY: .FORCE-GIT-VERSION-FILE
c6a5e403 86.PHONY: .FORCE-GIT-GUI-VARS