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