Merge branch 'pu' of git://repo.or.cz/git-gui into devel
[git/platforms.git] / git-gui / Makefile
blob6236dd6ad397e72956dfa43ec3c7add2698486a3
1 all::
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
18 ifndef SHELL_PATH
19 SHELL_PATH = /bin/sh
20 endif
22 ifndef gitexecdir
23 gitexecdir := $(shell git --exec-path)
24 endif
26 ifndef sharedir
27 sharedir := $(dir $(gitexecdir))share
28 endif
30 ifndef INSTALL
31 INSTALL = install
32 endif
34 RM_F ?= rm -f
35 RMDIR ?= rmdir
37 INSTALL_D0 = $(INSTALL) -d -m755 # space is required here
38 INSTALL_D1 =
39 INSTALL_R0 = $(INSTALL) -m644 # space is required here
40 INSTALL_R1 =
41 INSTALL_X0 = $(INSTALL) -m755 # space is required here
42 INSTALL_X1 =
43 INSTALL_L0 = rm -f # space is required here
44 INSTALL_L1 = && ln # space is required here
45 INSTALL_L2 =
46 INSTALL_L3 =
48 REMOVE_D0 = $(RMDIR) # space is required here
49 REMOVE_D1 = || true
50 REMOVE_F0 = $(RM_F) # space is required here
51 REMOVE_F1 =
52 CLEAN_DST = true
54 ifndef V
55 QUIET = @
56 QUIET_GEN = $(QUIET)echo ' ' GEN $@ &&
57 QUIET_BUILT_IN = $(QUIET)echo ' ' BUILTIN $@ &&
58 QUIET_INDEX = $(QUIET)echo ' ' INDEX $(dir $@) &&
59 QUIET_MSGFMT0 = $(QUIET)printf ' MSGFMT %12s ' $@ && v=`
60 QUIET_MSGFMT1 = 2>&1` && echo "$$v" | sed -e 's/fuzzy translations/fuzzy/' | sed -e 's/ messages//g'
61 QUIET_2DEVNULL = 2>/dev/null
63 INSTALL_D0 = dir=
64 INSTALL_D1 = && echo ' ' DEST $$dir && $(INSTALL) -d -m755 "$$dir"
65 INSTALL_R0 = src=
66 INSTALL_R1 = && echo ' ' INSTALL 644 `basename $$src` && $(INSTALL) -m644 $$src
67 INSTALL_X0 = src=
68 INSTALL_X1 = && echo ' ' INSTALL 755 `basename $$src` && $(INSTALL) -m755 $$src
70 INSTALL_L0 = dst=
71 INSTALL_L1 = && src=
72 INSTALL_L2 = && dst=
73 INSTALL_L3 = && echo ' ' 'LINK ' `basename "$$dst"` '->' `basename "$$src"` && rm -f "$$dst" && ln "$$src" "$$dst"
75 CLEAN_DST = echo ' ' UNINSTALL
76 REMOVE_D0 = dir=
77 REMOVE_D1 = && echo ' ' REMOVE $$dir && test -d "$$dir" && $(RMDIR) "$$dir" || true
78 REMOVE_F0 = dst=
79 REMOVE_F1 = && echo ' ' REMOVE `basename "$$dst"` && $(RM_F) "$$dst"
80 endif
82 TCL_PATH ?= tclsh
83 TCLTK_PATH ?= wish
85 ifeq ($(findstring $(MAKEFLAGS),s),s)
86 QUIET_GEN =
87 QUIET_BUILT_IN =
88 endif
90 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
91 gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
92 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
93 TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH))
94 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
95 TCLTK_PATH_SED = $(subst ','\'',$(subst \,\\,$(TCLTK_PATH)))
97 gg_libdir ?= $(sharedir)/git-gui/lib
98 libdir_SQ = $(subst ','\'',$(gg_libdir))
99 libdir_SED = $(subst ','\'',$(subst \,\\,$(gg_libdir)))
100 exedir = $(dir $(gitexecdir))share/git-gui/lib
102 GITGUI_SCRIPT := $$0
103 GITGUI_RELATIVE :=
105 ifeq ($(exedir),$(gg_libdir))
106 GITGUI_RELATIVE := 1
107 endif
109 ifeq ($(uname_O),Cygwin)
110 GITGUI_SCRIPT := `cygpath --windows --absolute "$(GITGUI_SCRIPT)"`
111 ifeq ($(GITGUI_RELATIVE),)
112 gg_libdir := $(shell cygpath --windows --absolute "$(gg_libdir)")
113 endif
114 endif
116 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
117 $(QUIET_GEN)rm -f $@ $@+ && \
118 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
119 -e '1,30s|^ argv0=$$0| argv0=$(GITGUI_SCRIPT)|' \
120 -e '1,30s|^ exec wish | exec '\''$(TCLTK_PATH_SED)'\'' |' \
121 -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
122 -e 's|@@GITGUI_RELATIVE@@|$(GITGUI_RELATIVE)|' \
123 -e '$(GITGUI_RELATIVE)s|@@GITGUI_LIBDIR@@|$(libdir_SED)|' \
124 $@.sh >$@+ && \
125 chmod +x $@+ && \
126 mv $@+ $@
128 $(GITGUI_BUILT_INS): git-gui
129 $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@
131 XGETTEXT ?= xgettext
132 MSGFMT ?= msgfmt
133 msgsdir = $(gg_libdir)/msgs
134 msgsdir_SQ = $(subst ','\'',$(msgsdir))
135 PO_TEMPLATE = po/git-gui.pot
136 ALL_POFILES = $(wildcard po/*.po)
137 ALL_MSGFILES = $(subst .po,.msg,$(ALL_POFILES))
139 $(PO_TEMPLATE): $(SCRIPT_SH) $(ALL_LIBFILES)
140 $(XGETTEXT) -kmc -LTcl -o $@ $(SCRIPT_SH) $(ALL_LIBFILES)
141 update-po:: $(PO_TEMPLATE)
142 $(foreach p, $(ALL_POFILES), echo Updating $p ; msgmerge -U $p $(PO_TEMPLATE) ; )
143 $(ALL_MSGFILES): %.msg : %.po
144 $(QUIET_MSGFMT0)$(MSGFMT) --statistics --tcl $< -l $(basename $(notdir $<)) -d $(dir $@) $(QUIET_MSGFMT1)
146 lib/tclIndex: $(ALL_LIBFILES)
147 $(QUIET_INDEX)if echo \
148 $(foreach p,$(PRELOAD_FILES),source $p\;) \
149 auto_mkindex lib '*.tcl' \
150 | $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \
151 else \
152 echo 1>&2 " * $(TCL_PATH) failed; using unoptimized loading"; \
153 rm -f $@ ; \
154 echo '# Autogenerated by git-gui Makefile' >$@ && \
155 echo >>$@ && \
156 $(foreach p,$(PRELOAD_FILES) $(ALL_LIBFILES),echo '$(subst lib/,,$p)' >>$@ &&) \
157 echo >>$@ ; \
160 # These can record GITGUI_VERSION
161 $(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE GIT-GUI-VARS
162 lib/tclIndex: GIT-GUI-VARS
164 TRACK_VARS = \
165 $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
166 $(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
167 $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
168 $(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
169 $(subst ','\'',gg_libdir='$(libdir_SQ)') \
170 #end TRACK_VARS
172 GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
173 @VARS='$(TRACK_VARS)'; \
174 if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
175 echo 1>&2 " * new locations or Tcl/Tk interpreter"; \
176 echo 1>$@ "$$VARS"; \
179 all:: $(ALL_PROGRAMS) lib/tclIndex $(ALL_MSGFILES)
181 install: all
182 $(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
183 $(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
184 $(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(INSTALL_L0)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L1)'$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' $(INSTALL_L2)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L3) &&) true
185 $(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(INSTALL_D1)
186 $(QUIET)$(INSTALL_R0)lib/tclIndex $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)'
187 $(QUIET)$(foreach p,$(ALL_LIBFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' &&) true
188 $(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(msgsdir_SQ)' $(INSTALL_D1)
189 $(QUIET)$(foreach p,$(ALL_MSGFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
191 uninstall:
192 $(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
193 $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
194 $(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
195 $(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(libdir_SQ)'
196 $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/tclIndex $(REMOVE_F1)
197 $(QUIET)$(foreach p,$(ALL_LIBFILES), $(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/$(notdir $p) $(REMOVE_F1) &&) true
198 $(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(msgsdir_SQ)'
199 $(QUIET)$(foreach p,$(ALL_MSGFILES), $(REMOVE_F0)'$(DESTDIR_SQ)$(msgsdir_SQ)'/$(notdir $p) $(REMOVE_F1) &&) true
200 $(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(REMOVE_D1)
201 $(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(msgsdir_SQ)' $(REMOVE_D1)
202 $(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(REMOVE_D1)
203 $(QUIET)$(REMOVE_D0)`dirname '$(DESTDIR_SQ)$(libdir_SQ)'` $(REMOVE_D1)
205 dist-version:
206 @mkdir -p $(TARDIR)
207 @echo $(GITGUI_VERSION) > $(TARDIR)/version
209 clean::
210 rm -f $(ALL_PROGRAMS) lib/tclIndex po/*.msg
211 rm -f GIT-VERSION-FILE GIT-GUI-VARS
213 .PHONY: all install uninstall dist-version clean
214 .PHONY: .FORCE-GIT-VERSION-FILE
215 .PHONY: .FORCE-GIT-GUI-VARS