tg.sh: use correct remote branch list for recurse_deps_internal
[topgit/pro.git] / Makefile.mak
blobfc86bf5effcbaed91ec0e0d57af3264a35e8d3f6
1 # Makefile.mak - POSIX Makefile.mak adjunct for TopGit
3 .POSIX:
5 # Default target is all
6 all:
8 # Makefile.sh sets many variables used by this Makefile.mak
10 include $(CONFIGMAK)
11 SHELL = $(SHELL_PATH)
13 all: \
14 shell_compatibility_test \
15 precheck \
16 tg $(commands_out) $(utils_out) $(awk_out) $(hooks_out) $(helpers_out) \
17 bin-wrappers/tg bin-wrappers/pre-commit $(help_out) tg-tg.txt
19 awk: $(awk_out)
20 hooks: $(hooks_out)
21 helpers: $(helpers_out)
23 please_set_SHELL_PATH_to_a_more_modern_shell: FORCE
24 @$$(:)
26 shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
28 # $(POUND) expands to a single '#' courtesy of Makefile.sh
29 AT = @
30 Q_ = $(AT)
31 Q_0 = $(Q_)
32 Q = $(Q_$(V))
33 QSED_ = $(AT)echo "[SED] $@" &&
34 QSED_0 = $(QSED_)
35 QSED = $(QSED_$(V))
36 QHELP_ = $(AT)CMD="$@" && CMD="$${CMD$(POUND)tg-}" && echo "[HELP] $${CMD%.txt}" &&
37 QHELP_0 = $(QHELP_)
38 QHELP = $(QHELP_$(V))
39 QHELPTG_ = $(AT)echo "[HELP] tg" &&
40 QHELPTG_0 = $(QHELPTG_)
41 QHELPTG = $(QHELPTG_$(V))
42 QHTML_ = $(AT)CMD="$@" && CMD="$${CMD$(POUND)tg-}" && echo "[HTML] $${CMD%.html}" &&
43 QHTML_0 = $(QHTML_)
44 QHTML = $(QHTML_$(V))
45 QHTMLTOPGIT_ = $(AT)echo "[HTML] topgit" &&
46 QHTMLTOPGIT_0 = $(QHTMLTOPGIT_)
47 QHTMLTOPGIT = $(QHTMLTOPGIT_$(V))
48 QWRAPPER_ = $(AT)echo "[WRAPPER] $@" &&
49 QWRAPPER_0 = $(QWRAPPER_)
50 QWRAPPER = $(QWRAPPER_$(V))
52 # Very important rule to avoid "accidents" caused by Makefile.sh's existence
53 # Some ridiculous "make" implementations will always implicitly "make Makefile"
54 # even though .POSIX: has been specified and that's definitely NOT POSIX!
55 Makefile:
56 @true
58 # Clean out the standard six single suffix inference rules to avoid accidents
59 .SUFFIXES: .c .sh .f .c˜ .sh˜ .f˜
60 .c:;
61 .f:;
62 .sh:;
63 .c~:;
64 .f~:;
65 .sh~:;
66 .SUFFIXES:
68 # The fatal flaw with .SUFFIXES is that while it's possible to add dependencies
69 # without listing rule commands, doing so prevents use of an inference rule
70 # because the dependency-adding-rule-with-no-commands is still considered a rule.
71 # Of course that means the free automatic dependency crated by an inference rule
72 # also can't be picked up but fortunately we have DEPFILE instead.
73 include $(DEPFILE)
75 tg $(commands_out) $(utils_out) $(hooks_out) $(helpers_out): Makefile Makefile.mak Makefile.sh TG-BUILD-SETTINGS
76 $(QSED)sed \
77 -e '1s|#!.*/sh|#!$(SHELL_PATH)|' \
78 -e '1s|#!.*/awk|#!$(AWK_PREFIX)$(AWK_PATH)|' \
79 -e 's#@cmddir@#$(cmddir)#g;' \
80 -e 's#@hooksdir@#$(hooksdir)#g' \
81 -e 's#@bindir@#$(bindir)#g' \
82 -e 's#@sharedir@#$(sharedir)#g' \
83 -e 's#@mingitver@#$(GIT_MINIMUM_VERSION)#g' \
84 -e 's#@tgsthelpusage@#$(TG_STATUS_HELP_USAGE)#g' \
85 -e 's#@SHELL_PATH@#$(SHELL_PATH_SQ)#g' \
86 -e 's#@AWK_PATH@#$(AWK_PATH_SQ)#g' \
87 $(version_arg) \
88 "$@.sh" >"$@+" && \
89 chmod +x "$@+" && \
90 mv "$@+" "$@"
92 tg--awksome: $(awk_out)
93 $(awk_out): Makefile TG-BUILD-SETTINGS
94 $(QSED)sed \
95 -e '1s|#!.*/awk|#!$(AWK_PREFIX)$(AWK_PATH_SQ)|' \
96 "$@.awk" >"$@+" && \
97 chmod +x "$@+" && \
98 mv "$@+" "$@"
100 bin-wrappers/tg : tg
101 $(QWRAPPER){ [ -d bin-wrappers ] || mkdir bin-wrappers; } && \
102 echo '#!$(SHELL_PATH_SQ)' >"$@" && \
103 curdir="$$(pwd -P)" && \
104 echo "TG_INST_BINDIR='$$curdir' && export TG_INST_BINDIR" >>"$@" && \
105 echo "TG_INST_CMDDIR='$$curdir' && export TG_INST_CMDDIR" >>"$@" && \
106 echo "TG_INST_SHAREDIR='$$curdir' && export TG_INST_SHAREDIR" >>"$@" && \
107 echo "TG_INST_HOOKSDIR='$$curdir/bin-wrappers' && export TG_INST_HOOKSDIR" >>"$@" && \
108 echo '[ -n "$$tg__include" ] || exec $(SHELL_PATH_SQ) -c '\''. "$$TG_INST_BINDIR/tg"'\'' "$$0" "$$@" || exit $$?' >>"$@" && \
109 echo ". '$$curdir/tg'" >>"$@" && sed <"$@" "/exec.* -c /s/ -c / -x -c /" >"$@x" && \
110 chmod a+x "$@" "$@x"
112 bin-wrappers/pre-commit : hooks/pre-commit
113 $(QWRAPPER){ [ -d bin-wrappers ] || mkdir bin-wrappers; } && \
114 echo '#!$(SHELL_PATH_SQ)' >"$@" && \
115 curdir="$$(pwd -P)" && \
116 echo "TG_INST_BINDIR='$$curdir' && export TG_INST_BINDIR" >>"$@" && \
117 echo "TG_INST_CMDDIR='$$curdir' && export TG_INST_CMDDIR" >>"$@" && \
118 echo "TG_INST_SHAREDIR='$$curdir' && export TG_INST_SHAREDIR" >>"$@" && \
119 echo "TG_INST_HOOKSDIR='$$curdir/bin-wrappers' && export TG_INST_HOOKSDIR" >>"$@" && \
120 echo ". '$$curdir/hooks/pre-commit'" >>"$@" && \
121 chmod a+x "$@"
123 $(help_out): README create-help.sh
124 $(QHELP)CMD="$@" && CMD="$${CMD#tg-}" && CMD="$${CMD%.txt}" && \
125 $(SHELL_PATH) ./create-help.sh "$$CMD"
127 doc: html
129 install-doc: install-html
131 html: topgit.html $(html_out)
133 tg-tg.txt: README create-html-usage.pl $(commands_in)
134 $(QHELPTG)perl ./create-html-usage.pl --text < README > $@
136 topgit.html: README create-html-usage.pl $(commands_in)
137 $(QHTMLTOPGIT)perl ./create-html-usage.pl < README | rst2html.py - $@
139 $(html_out): create-html.sh
140 $(QHTML)CMD="$@" && CMD="$${CMD#tg-}" && CMD="$${CMD%.html}" && \
141 $(SHELL_PATH) ./create-html.sh "$$CMD"
143 precheck: precheck_DESTDIR_$(DESTDIRBOOL)
145 precheck_DESTDIR_No: tg FORCE
146 $(Q)./tg precheck
147 precheck_DESTDIR_Yes: FORCE
148 $(Q)echo "skipping precheck because DESTDIR is set"
150 install: all FORCE
151 install -d -m 755 "$(DESTDIR)$(bindir)"
152 install tg "$(DESTDIR)$(bindir)"
153 install -d -m 755 "$(DESTDIR)$(cmddir)"
154 install $(commands_out) $(utils_out) "$(DESTDIR)$(cmddir)"
155 install -d -m 755 "$(DESTDIR)$(cmddir)/awk"
156 install $(awk_out) "$(DESTDIR)$(cmddir)/awk"
157 install -d -m 755 "$(DESTDIR)$(hooksdir)"
158 install $(hooks_out) "$(DESTDIR)$(hooksdir)"
159 install -d -m 755 "$(DESTDIR)$(sharedir)"
160 install -m 644 $(help_out) tg-tg.txt "$(DESTDIR)$(sharedir)"
162 install-html: html FORCE
163 install -d -m 755 "$(DESTDIR)$(sharedir)"
164 install -m 644 topgit.html $(html_out) "$(DESTDIR)$(sharedir)"
166 clean: FORCE
167 rm -f tg $(commands_out) $(utils_out) $(awk_out) $(hooks_out) $(helpers_out) $(help_out) tg-tg.txt topgit.html $(html_out)
168 rm -f TG-BUILD-SETTINGS Makefile.dep Makefile.var
169 rm -rf bin-wrappers
170 +-$(Q)cd t && $(MAKE) clean
172 BUILD_SETTINGS = \
173 bs() { printf "%s\\n" \
174 "TG_INST_BINDIR='$(bindir)'" \
175 "TG_INST_CMDDIR='$(cmddir)'" \
176 "TG_INST_HOOKSDIR='$(hooksdir)'" \
177 "TG_INST_SHAREDIR='$(sharedir)'" \
178 "SHELL_PATH='$(SHELL_PATH)'" \
179 "AWK_PATH='$(AWK_PATH)'" \
180 "TG_VERSION='$(version)'" \
181 "TG_GIT_MINIMUM_VERSION='$(GIT_MINIMUM_VERSION)'" \
184 # Makefile.sh sets FORCE_SETTINGS_BUILD to FORCE and pre-runs
185 # make -f Makefile.mak TG-BUILD-SETTINGS thus avoiding this always
186 # causing the targets that depend on it to build while still forcing
187 # a rebuild if any settings actually change.
188 TG-BUILD-SETTINGS: $(FORCE_SETTINGS_BUILD)
189 $(Q)$(BUILD_SETTINGS);if test x"$$(bs)" != x"`cat \"$@\" 2>/dev/null`"; then \
190 echo "* new build settings"; \
191 bs >"$@"; \
194 test: all FORCE
195 +$(Q)cd t && $(MAKE) all
197 FORCE: __file_which_should_not_exist
199 # This "phony" target must have at least one command otherwise it will not
200 # actually run anything and so will not actually trigger the rules that depend
201 # on FORCE to run either. By using "true" instead of ":" "make"s that
202 # short-circuit directly to execvp should be able to run "true" directly.
203 __file_which_should_not_exist:
204 -@true