1 # Makefile.mak - POSIX Makefile.mak adjunct for TopGit
8 ## V - set to 1 to get more verbose rule output
10 ## Any value other than empty or 0 will also activate verbose mode
12 ## DESTDIR - installation path prefix
14 ## The value is prefixed verbatim to the installation paths when
15 ## using any of the "install" targets but is otherwise ignored.
16 ## This allows the executables to be configured for one location
17 ## but installed to an alternate location before being moved to
18 ## their final location. The executables will not work correctly
19 ## until they are then relocated into their final location.
21 ## RST2HTML - location of rst2html.py
22 ## Default is "rst2html"
23 ## Only required to `make doc` aka `make html` (i.e. topgit.html)
24 ## If "rst2html" is not in $PATH this must be set
25 ## in order to successfully `make doc` (or `make html`)
28 # Default target is all
31 # Makefile.sh sets many variables used by this Makefile.mak
37 shell_compatibility_test \
39 tg
$(commands_out
) $(utils_out
) $(awk_out
) $(hooks_out
) $(helpers_out
) \
40 bin-wrappers
/tg bin-wrappers
/pre-commit
$(help_out
) tg-tg.txt
42 settings
: TG-BUILD-SETTINGS FORCE
43 +$(Q
)cd t
&& $(MAKE
) settings
47 helpers
: $(helpers_out
)
49 please_set_SHELL_PATH_to_a_more_modern_shell
: FORCE
52 shell_compatibility_test
: please_set_SHELL_PATH_to_a_more_modern_shell
54 # $(POUND) expands to a single '#' courtesy of Makefile.sh
59 QPOUND_
= $(AT
)$(POUND
)
61 QPOUND
= $(QPOUND_
$(V
))
62 QSED_
= $(AT
)echo
"[SED] $@" &&
65 QHELP_
= $(AT
)CMD
="$@" && CMD
="$${CMD$(POUND)tg-}" && echo
"[HELP] $${CMD%.txt}" &&
68 QHELPTG_
= $(AT
)echo
"[HELP] tg" &&
69 QHELPTG_0
= $(QHELPTG_
)
70 QHELPTG
= $(QHELPTG_
$(V
))
71 QHTML_
= $(AT
)CMD
="$@" && CMD
="$${CMD$(POUND)tg-}" && echo
"[HTML] $${CMD%.html}" &&
74 QHTMLTOPGIT_
= $(AT
)echo
"[HTML] topgit" &&
75 QHTMLTOPGIT_0
= $(QHTMLTOPGIT_
)
76 QHTMLTOPGIT
= $(QHTMLTOPGIT_
$(V
))
77 QWRAPPER_
= $(AT
)echo
"[WRAPPER] $@" &&
78 QWRAPPER_0
= $(QWRAPPER_
)
79 QWRAPPER
= $(QWRAPPER_
$(V
))
81 # Very important rule to avoid "accidents" caused by Makefile.sh's existence
82 # Some ridiculous "make" implementations will always implicitly "make Makefile"
83 # even though .POSIX: has been specified and that's definitely NOT POSIX!
87 # Clean out the standard six single suffix inference rules to avoid accidents
88 .SUFFIXES
: .c .sh .f .c˜ .sh˜ .f˜
97 # The fatal flaw with .SUFFIXES is that while it's possible to add dependencies
98 # without listing rule commands, doing so prevents use of an inference rule
99 # because the dependency-adding-rule-with-no-commands is still considered a rule.
100 # Of course that means the free automatic dependency crated by an inference rule
101 # also can't be picked up but fortunately we have DEPFILE instead.
104 tg
$(commands_out
) $(utils_out
) $(hooks_out
) $(helpers_out
): Makefile Makefile.mak Makefile.sh TG-BUILD-SETTINGS
106 -e
'1s|#!.*/sh|#!$(SHELL_PATH)|' \
107 -e
'1s|#!.*/awk|#!$(AWK_PREFIX)$(AWK_PATH)|' \
108 -e
's#@cmddir@#$(cmddir)#g;' \
109 -e
's#@hooksdir@#$(hooksdir)#g' \
110 -e
's#@bindir@#$(bindir)#g' \
111 -e
's#@sharedir@#$(sharedir)#g' \
112 -e
's#@mingitver@#$(GIT_MINIMUM_VERSION)#g' \
113 -e
's#@tgsthelpusage@#$(TG_STATUS_HELP_USAGE)#g' \
114 -e
's#@SHELL_PATH@#$(SHELL_PATH_SQ)#g' \
115 -e
's#@AWK_PATH@#$(AWK_PATH_SQ)#g' \
121 tg--awksome
: $(awk_out
)
122 $(awk_out
): Makefile TG-BUILD-SETTINGS
124 -e
'1s|#!.*/awk|#!$(AWK_PREFIX)$(AWK_PATH_SQ)|' \
125 <"$@.awk" >"$@+" && \
130 $(QWRAPPER
){ [ -d bin-wrappers
] || mkdir
-p bin-wrappers
; } && \
131 echo
'#!$(SHELL_PATH_SQ)' >"$@" && \
132 curdir
="$$(pwd -P)" && \
133 echo
"TG_INST_BINDIR='$$curdir' && export TG_INST_BINDIR" >>"$@" && \
134 echo
"TG_INST_CMDDIR='$$curdir' && export TG_INST_CMDDIR" >>"$@" && \
135 echo
"TG_INST_SHAREDIR='$$curdir' && export TG_INST_SHAREDIR" >>"$@" && \
136 echo
"TG_INST_HOOKSDIR='$$curdir/bin-wrappers' && export TG_INST_HOOKSDIR" >>"$@" && \
137 echo
'[ -n "$$tg__include" ] || exec $(SHELL_PATH_SQ) -c '\''. "$$TG_INST_BINDIR/tg"'\'' "$$0" "$$@" || exit $$?' >>"$@" && \
138 echo
". '$$curdir/tg'" >>"$@" && sed
<"$@" "/exec.* -c /s/ -c / -x -c /" >"$@x" && \
141 bin-wrappers
/pre-commit
: hooks
/pre-commit
142 $(QWRAPPER
){ [ -d bin-wrappers
] || mkdir
-p bin-wrappers
; } && \
143 echo
'#!$(SHELL_PATH_SQ)' >"$@" && \
144 curdir
="$$(pwd -P)" && \
145 echo
"TG_INST_BINDIR='$$curdir' && export TG_INST_BINDIR" >>"$@" && \
146 echo
"TG_INST_CMDDIR='$$curdir' && export TG_INST_CMDDIR" >>"$@" && \
147 echo
"TG_INST_SHAREDIR='$$curdir' && export TG_INST_SHAREDIR" >>"$@" && \
148 echo
"TG_INST_HOOKSDIR='$$curdir/bin-wrappers' && export TG_INST_HOOKSDIR" >>"$@" && \
149 echo
". '$$curdir/hooks/pre-commit'" >>"$@" && \
152 $(help_out
): README create-help.sh polish-help-txt.pl
153 $(QHELP
)CMD
="$@" && CMD
="$${CMD#tg-}" && CMD
="$${CMD%.txt}" && \
154 $(SHELL_PATH
) .
/create-help.sh
"$$CMD"
158 install-doc
: install-html
160 html
: topgit.html
$(html_out
)
162 tg-tg.txt
: README create-html-usage.pl
$(commands_in
)
163 $(QHELPTG
)perl .
/create-html-usage.pl
--text
< README
> $@
165 topgit.html
: README create-html-usage.pl
$(commands_in
)
166 $(Q
)command
-v
"$${RST2HTML:-rst2html}" >/dev
/null || \
167 { echo
"need $${RST2HTML:-rst2html} to make $@" >&2; exit
1; }
168 $(QPOUND
)echo
"# \$${RST2HTML:-rst2html} is \"$${RST2HTML:-rst2html}\""
169 $(QHTMLTOPGIT
)perl .
/create-html-usage.pl
< README |
"$${RST2HTML:-rst2html}" - $@
&& \
170 perl
-i
-pe
's/ /\ /g' "$@"
172 $(html_out
): create-html.sh
173 $(QHTML
)CMD
="$@" && CMD
="$${CMD#tg-}" && CMD
="$${CMD%.html}" && \
174 $(SHELL_PATH
) .
/create-html.sh
"$$CMD"
176 precheck
: precheck_DESTDIR_
$(DESTDIRBOOL
)
178 precheck_DESTDIR_No
: tg FORCE
180 precheck_DESTDIR_Yes
: FORCE
181 $(Q
)echo
"skipping precheck because DESTDIR is set"
184 install -d
-m
755 "$(DESTDIR)$(bindir)"
185 install tg
"$(DESTDIR)$(bindir)"
186 install -d
-m
755 "$(DESTDIR)$(cmddir)"
187 install $(commands_out
) $(utils_out
) "$(DESTDIR)$(cmddir)"
188 install -d
-m
755 "$(DESTDIR)$(cmddir)/awk"
189 install $(awk_out
) "$(DESTDIR)$(cmddir)/awk"
190 install -d
-m
755 "$(DESTDIR)$(hooksdir)"
191 install $(hooks_out
) "$(DESTDIR)$(hooksdir)"
192 install -d
-m
755 "$(DESTDIR)$(sharedir)"
193 install -m
644 $(help_out
) tg-tg.txt
"$(DESTDIR)$(sharedir)"
195 install-html
: html FORCE
196 install -d
-m
755 "$(DESTDIR)$(sharedir)"
197 install -m
644 topgit.html
$(html_out
) "$(DESTDIR)$(sharedir)"
200 rm -f tg
$(commands_out
) $(utils_out
) $(awk_out
) $(hooks_out
) $(helpers_out
) $(help_out
) tg-tg.txt topgit.html
$(html_out
)
201 rm -f TG-BUILD-SETTINGS Makefile.dep Makefile.var
203 +-$(Q
)cd t
&& $(MAKE
) clean
206 bs
() { printf
"%s\\n" \
207 "TG_INST_BINDIR='$(bindir)'" \
208 "TG_INST_CMDDIR='$(cmddir)'" \
209 "TG_INST_HOOKSDIR='$(hooksdir)'" \
210 "TG_INST_SHAREDIR='$(sharedir)'" \
211 "SHELL_PATH='$(SHELL_PATH)'" \
212 "AWK_PATH='$(AWK_PATH)'" \
213 "TG_VERSION='$(version)'" \
214 "TG_GIT_MINIMUM_VERSION='$(GIT_MINIMUM_VERSION)'" \
217 # Makefile.sh sets FORCE_SETTINGS_BUILD to FORCE and pre-runs
218 # make -f Makefile.mak TG-BUILD-SETTINGS thus avoiding this always
219 # causing the targets that depend on it to build while still forcing
220 # a rebuild if any settings actually change.
221 TG-BUILD-SETTINGS
: $(CONFIGDEPS
) $(FORCE_SETTINGS_BUILD
)
222 $(Q
)$(BUILD_SETTINGS
);if
test x
"$$(bs)" != x
"`cat \"$@\" 2>/dev/null`"; then \
223 echo
"* new build settings"; \
225 elif
test z
"$(FORCE_SETTINGS_BUILD)" = z
; then touch
"$@"; fi
228 +$(Q
)cd t
&& $(MAKE
) all
230 FORCE
: __file_which_should_not_exist
232 # This "phony" target must have at least one command otherwise it will not
233 # actually run anything and so will not actually trigger the rules that depend
234 # on FORCE to run either. By using "true" instead of ":" "make"s that
235 # short-circuit directly to execvp should be able to run "true" directly.
236 __file_which_should_not_exist
: