1 # Makefile.mak - POSIX Makefile.mak adjunct for TopGit
5 # Default target is all
8 # Makefile.sh sets many variables used by this Makefile.mak
14 shell_compatibility_test \
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
24 helpers
: $(helpers_out
)
26 please_set_SHELL_PATH_to_a_more_modern_shell
: FORCE
29 shell_compatibility_test
: please_set_SHELL_PATH_to_a_more_modern_shell
31 # $(POUND) expands to a single '#' courtesy of Makefile.sh
36 QSED_
= $(AT
)echo
"[SED] $@" &&
39 QHELP_
= $(AT
)CMD
="$@" && CMD
="$${CMD$(POUND)tg-}" && echo
"[HELP] $${CMD%.txt}" &&
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}" &&
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!
61 # Clean out the standard six single suffix inference rules to avoid accidents
62 .SUFFIXES
: .c .sh .f .c˜ .sh˜ .f˜
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.
78 tg
$(commands_out
) $(utils_out
) $(hooks_out
) $(helpers_out
): Makefile Makefile.mak Makefile.sh TG-BUILD-SETTINGS
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' \
95 tg--awksome
: $(awk_out
)
96 $(awk_out
): Makefile TG-BUILD-SETTINGS
98 -e
'1s|#!.*/awk|#!$(AWK_PREFIX)$(AWK_PATH_SQ)|' \
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" && \
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'" >>"$@" && \
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"
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/ /\ /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
151 precheck_DESTDIR_Yes
: FORCE
152 $(Q
)echo
"skipping precheck because DESTDIR is set"
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)"
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
174 +-$(Q
)cd t
&& $(MAKE
) clean
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"; \
196 elif
test z
"$(FORCE_SETTINGS_BUILD)" = z
; then touch
"$@"; fi
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
: