Merge branch 'maint' of git://repo.or.cz/git-gui into maint
[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
14 ifndef SHELL_PATH
15         SHELL_PATH = /bin/sh
16 endif
17
18 ifndef gitexecdir
19         gitexecdir := $(shell git --exec-path)
20 endif
21
22 ifndef INSTALL
23         INSTALL = install
24 endif
25
26 ifndef V
27         QUIET_GEN      = @echo '   ' GEN $@;
28         QUIET_BUILT_IN = @echo '   ' BUILTIN $@;
29 endif
30
31 ifeq ($(findstring $(MAKEFLAGS),s),s)
32 QUIET_GEN =
33 QUIET_BUILT_IN =
34 endif
35
36 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
37 gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
38 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
39
40 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
41         $(QUIET_GEN)rm -f $@ $@+ && \
42         sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
43                 -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
44                 $@.sh >$@+ && \
45         chmod +x $@+ && \
46         mv $@+ $@
47
48 $(GITGUI_BUILT_INS): git-gui
49         $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@
50
51 # These can record GITGUI_VERSION
52 $(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE
53
54 all:: $(ALL_PROGRAMS)
55
56 install: all
57         $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
58         $(INSTALL) git-gui '$(DESTDIR_SQ)$(gitexecdir_SQ)'
59         $(foreach p,$(GITGUI_BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
60
61 dist-version:
62         @mkdir -p $(TARDIR)
63         @echo $(GITGUI_VERSION) > $(TARDIR)/version
64
65 clean::
66         rm -f $(ALL_PROGRAMS) GIT-VERSION-FILE
67
68 .PHONY: all install dist-version clean
69 .PHONY: .FORCE-GIT-VERSION-FILE