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