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