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