topgit_*_prepare.awk: do not append ^{} to missing
[topgit/pro.git] / Makefile.mak
blobc1edc07b4fda3e82861d174e0c466df6370e66b4
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 - $@ && \
141 perl -i -pe 's/&nbsp;/\&#160;/g' "$@"
143 $(html_out): create-html.sh
144 $(QHTML)CMD="$@" && CMD="$${CMD#tg-}" && CMD="$${CMD%.html}" && \
145 $(SHELL_PATH) ./create-html.sh "$$CMD"
147 precheck: precheck_DESTDIR_$(DESTDIRBOOL)
149 precheck_DESTDIR_No: tg FORCE
150 $(Q)./tg precheck
151 precheck_DESTDIR_Yes: FORCE
152 $(Q)echo "skipping precheck because DESTDIR is set"
154 install: all FORCE
155 install -d -m 755 "$(DESTDIR)$(bindir)"
156 install tg "$(DESTDIR)$(bindir)"
157 install -d -m 755 "$(DESTDIR)$(cmddir)"
158 install $(commands_out) $(utils_out) "$(DESTDIR)$(cmddir)"
159 install -d -m 755 "$(DESTDIR)$(cmddir)/awk"
160 install $(awk_out) "$(DESTDIR)$(cmddir)/awk"
161 install -d -m 755 "$(DESTDIR)$(hooksdir)"
162 install $(hooks_out) "$(DESTDIR)$(hooksdir)"
163 install -d -m 755 "$(DESTDIR)$(sharedir)"
164 install -m 644 $(help_out) tg-tg.txt "$(DESTDIR)$(sharedir)"
166 install-html: html FORCE
167 install -d -m 755 "$(DESTDIR)$(sharedir)"
168 install -m 644 topgit.html $(html_out) "$(DESTDIR)$(sharedir)"
170 clean: FORCE
171 rm -f tg $(commands_out) $(utils_out) $(awk_out) $(hooks_out) $(helpers_out) $(help_out) tg-tg.txt topgit.html $(html_out)
172 rm -f TG-BUILD-SETTINGS Makefile.dep Makefile.var
173 rm -rf bin-wrappers
174 +-$(Q)cd t && $(MAKE) clean
176 BUILD_SETTINGS = \
177 bs() { printf "%s\\n" \
178 "TG_INST_BINDIR='$(bindir)'" \
179 "TG_INST_CMDDIR='$(cmddir)'" \
180 "TG_INST_HOOKSDIR='$(hooksdir)'" \
181 "TG_INST_SHAREDIR='$(sharedir)'" \
182 "SHELL_PATH='$(SHELL_PATH)'" \
183 "AWK_PATH='$(AWK_PATH)'" \
184 "TG_VERSION='$(version)'" \
185 "TG_GIT_MINIMUM_VERSION='$(GIT_MINIMUM_VERSION)'" \
188 # Makefile.sh sets FORCE_SETTINGS_BUILD to FORCE and pre-runs
189 # make -f Makefile.mak TG-BUILD-SETTINGS thus avoiding this always
190 # causing the targets that depend on it to build while still forcing
191 # a rebuild if any settings actually change.
192 TG-BUILD-SETTINGS: $(CONFIGDEPS) $(FORCE_SETTINGS_BUILD)
193 $(Q)$(BUILD_SETTINGS);if test x"$$(bs)" != x"`cat \"$@\" 2>/dev/null`"; then \
194 echo "* new build settings"; \
195 bs >"$@"; \
196 elif test z"$(FORCE_SETTINGS_BUILD)" = z; then touch "$@"; fi
198 test: all FORCE
199 +$(Q)cd t && $(MAKE) all
201 FORCE: __file_which_should_not_exist
203 # This "phony" target must have at least one command otherwise it will not
204 # actually run anything and so will not actually trigger the rules that depend
205 # on FORCE to run either. By using "true" instead of ":" "make"s that
206 # short-circuit directly to execvp should be able to run "true" directly.
207 __file_which_should_not_exist:
208 -@true