git-gui: Fix missing i18n markup in push/fetch windows
[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
82a2d6bd
SP
10uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
11
bb616ddd 12SCRIPT_SH = git-gui.sh
41bdcda3 13GITGUI_BUILT_INS = git-citool
bb616ddd 14ALL_PROGRAMS = $(GITGUI_BUILT_INS) $(patsubst %.sh,%,$(SCRIPT_SH))
f522c9b5 15ALL_LIBFILES = $(wildcard lib/*.tcl)
b9e7efb8 16PRELOAD_FILES = lib/class.tcl
41bdcda3
SP
17
18ifndef SHELL_PATH
19 SHELL_PATH = /bin/sh
20endif
b3678bac 21
663e7cf8
SP
22ifndef gitexecdir
23 gitexecdir := $(shell git --exec-path)
24endif
25
f522c9b5 26ifndef sharedir
ea75ee35 27 sharedir := $(dir $(gitexecdir))share
f522c9b5
SP
28endif
29
663e7cf8
SP
30ifndef INSTALL
31 INSTALL = install
32endif
b3678bac 33
042f53c5
SP
34RM_F ?= rm -f
35RMDIR ?= rmdir
36
573fe6d7
SP
37INSTALL_D0 = $(INSTALL) -d -m755 # space is required here
38INSTALL_D1 =
39INSTALL_R0 = $(INSTALL) -m644 # space is required here
40INSTALL_R1 =
41INSTALL_X0 = $(INSTALL) -m755 # space is required here
42INSTALL_X1 =
43INSTALL_L0 = rm -f # space is required here
44INSTALL_L1 = && ln # space is required here
45INSTALL_L2 =
46INSTALL_L3 =
47
042f53c5
SP
48REMOVE_D0 = $(RMDIR) # space is required here
49REMOVE_D1 = || true
50REMOVE_F0 = $(RM_F) # space is required here
51REMOVE_F1 =
52CLEAN_DST = true
53
0b5ea163 54ifndef V
573fe6d7
SP
55 QUIET = @
56 QUIET_GEN = $(QUIET)echo ' ' GEN $@ &&
57 QUIET_BUILT_IN = $(QUIET)echo ' ' BUILTIN $@ &&
58 QUIET_INDEX = $(QUIET)echo ' ' INDEX $(dir $@) &&
12fb2233
SP
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'
b9e7efb8 61 QUIET_2DEVNULL = 2>/dev/null
573fe6d7
SP
62
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
69
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"
042f53c5
SP
74
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"
0b5ea163
SP
80endif
81
f522c9b5 82TCL_PATH ?= tclsh
845d377b
JH
83TCLTK_PATH ?= wish
84
0c3b4aac
AR
85ifeq ($(findstring $(MAKEFLAGS),s),s)
86QUIET_GEN =
87QUIET_BUILT_IN =
88endif
89
b3678bac
SP
90DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
91gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
41bdcda3 92SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
b9e7efb8 93TCL_PATH_SQ = $(subst ','\'',$(TCL_PATH))
845d377b 94TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
41bdcda3 95
c63fe3b2
SP
96gg_libdir ?= $(sharedir)/git-gui/lib
97libdir_SQ = $(subst ','\'',$(gg_libdir))
f522c9b5 98
ea75ee35
SP
99exedir = $(dir $(gitexecdir))share/git-gui/lib
100exedir_SQ = $(subst ','\'',$(exedir))
101
bb616ddd 102$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
0b5ea163 103 $(QUIET_GEN)rm -f $@ $@+ && \
82a2d6bd 104 GITGUI_RELATIVE= && \
ea75ee35 105 if test '$(exedir_SQ)' = '$(libdir_SQ)'; then \
82a2d6bd
SP
106 if test "$(uname_O)" = Cygwin; \
107 then GITGUI_RELATIVE= ; \
108 else GITGUI_RELATIVE=1; \
109 fi; \
ea75ee35 110 fi && \
bb616ddd 111 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
4e817d1a 112 -e 's|^ exec wish "$$0"| exec $(subst |,'\|',$(TCLTK_PATH_SQ)) "$$0"|' \
7e81d4ee 113 -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
ea75ee35
SP
114 -e 's|@@GITGUI_RELATIVE@@|'$$GITGUI_RELATIVE'|' \
115 -e $$GITGUI_RELATIVE's|@@GITGUI_LIBDIR@@|$(libdir_SQ)|' \
0b5ea163 116 $@.sh >$@+ && \
0b5ea163 117 chmod +x $@+ && \
41bdcda3
SP
118 mv $@+ $@
119
120$(GITGUI_BUILT_INS): git-gui
0b5ea163 121 $(QUIET_BUILT_IN)rm -f $@ && ln git-gui $@
41bdcda3 122
38450480 123XGETTEXT ?= xgettext
87b63de4 124MSGFMT ?= msgfmt
b2bd3100 125msgsdir = $(gg_libdir)/msgs
38450480
CS
126msgsdir_SQ = $(subst ','\'',$(msgsdir))
127PO_TEMPLATE = po/git-gui.pot
128ALL_POFILES = $(wildcard po/*.po)
129ALL_MSGFILES = $(subst .po,.msg,$(ALL_POFILES))
130
131$(PO_TEMPLATE): $(SCRIPT_SH) $(ALL_LIBFILES)
132 $(XGETTEXT) -kmc -LTcl -o $@ $(SCRIPT_SH) $(ALL_LIBFILES)
133update-po:: $(PO_TEMPLATE)
134 $(foreach p, $(ALL_POFILES), echo Updating $p ; msgmerge -U $p $(PO_TEMPLATE) ; )
135$(ALL_MSGFILES): %.msg : %.po
87b63de4 136 $(QUIET_MSGFMT0)$(MSGFMT) --statistics --tcl $< -l $(basename $(notdir $<)) -d $(dir $@) $(QUIET_MSGFMT1)
38450480 137
f522c9b5 138lib/tclIndex: $(ALL_LIBFILES)
b9e7efb8
SP
139 $(QUIET_INDEX)if echo \
140 $(foreach p,$(PRELOAD_FILES),source $p\;) \
1f07c4e5 141 auto_mkindex lib '*.tcl' \
b9e7efb8
SP
142 | $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \
143 else \
144 echo 1>&2 " * $(TCL_PATH) failed; using unoptimized loading"; \
145 rm -f $@ ; \
146 echo '# Autogenerated by git-gui Makefile' >$@ && \
147 echo >>$@ && \
148 $(foreach p,$(PRELOAD_FILES) $(ALL_LIBFILES),echo '$(subst lib/,,$p)' >>$@ &&) \
149 echo >>$@ ; \
150 fi
f522c9b5 151
bb616ddd 152# These can record GITGUI_VERSION
c6a5e403 153$(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE GIT-GUI-VARS
b9e7efb8 154lib/tclIndex: GIT-GUI-VARS
c6a5e403
SP
155
156TRACK_VARS = \
157 $(subst ','\'',SHELL_PATH='$(SHELL_PATH_SQ)') \
b9e7efb8 158 $(subst ','\'',TCL_PATH='$(TCL_PATH_SQ)') \
c6a5e403 159 $(subst ','\'',TCLTK_PATH='$(TCLTK_PATH_SQ)') \
ea75ee35 160 $(subst ','\'',gitexecdir='$(gitexecdir_SQ)') \
c63fe3b2 161 $(subst ','\'',gg_libdir='$(libdir_SQ)') \
c6a5e403
SP
162#end TRACK_VARS
163
164GIT-GUI-VARS: .FORCE-GIT-GUI-VARS
165 @VARS='$(TRACK_VARS)'; \
166 if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
167 echo 1>&2 " * new locations or Tcl/Tk interpreter"; \
168 echo 1>$@ "$$VARS"; \
169 fi
bb616ddd 170
38450480 171all:: $(ALL_PROGRAMS) lib/tclIndex $(ALL_MSGFILES)
b3678bac
SP
172
173install: all
573fe6d7
SP
174 $(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
175 $(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
176 $(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
177 $(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(INSTALL_D1)
178 $(QUIET)$(INSTALL_R0)lib/tclIndex $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)'
179 $(QUIET)$(foreach p,$(ALL_LIBFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' &&) true
38450480
CS
180 $(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(msgsdir_SQ)' $(INSTALL_D1)
181 $(QUIET)$(foreach p,$(ALL_MSGFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
41bdcda3 182
042f53c5
SP
183uninstall:
184 $(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
185 $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
186 $(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
187 $(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(libdir_SQ)'
188 $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/tclIndex $(REMOVE_F1)
189 $(QUIET)$(foreach p,$(ALL_LIBFILES), $(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/$(notdir $p) $(REMOVE_F1) &&) true
4baba57f
SP
190 $(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(msgsdir_SQ)'
191 $(QUIET)$(foreach p,$(ALL_MSGFILES), $(REMOVE_F0)'$(DESTDIR_SQ)$(msgsdir_SQ)'/$(notdir $p) $(REMOVE_F1) &&) true
042f53c5 192 $(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(REMOVE_D1)
4baba57f 193 $(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(msgsdir_SQ)' $(REMOVE_D1)
042f53c5
SP
194 $(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(REMOVE_D1)
195 $(QUIET)$(REMOVE_D0)`dirname '$(DESTDIR_SQ)$(libdir_SQ)'` $(REMOVE_D1)
196
bb616ddd 197dist-version:
5d643cd3
SP
198 @mkdir -p $(TARDIR)
199 @echo $(GITGUI_VERSION) > $(TARDIR)/version
200
41bdcda3 201clean::
38450480 202 rm -f $(ALL_PROGRAMS) lib/tclIndex po/*.msg
f522c9b5 203 rm -f GIT-VERSION-FILE GIT-GUI-VARS
f1cee4e6 204
042f53c5 205.PHONY: all install uninstall dist-version clean
f1cee4e6 206.PHONY: .FORCE-GIT-VERSION-FILE
c6a5e403 207.PHONY: .FORCE-GIT-GUI-VARS