Mercurial > projects > dstress
annotate Makefile @ 92:df8fe715d493
added support for multifile "nocompile" targets
author | thomask |
---|---|
date | Mon, 01 Nov 2004 19:33:03 +0000 |
parents | 659bb018c489 |
children | aa6478748245 |
rev | line source |
---|---|
46 | 1 # GnuMakefile for DStress http://dmd.kuehne.cn/dstress.html |
2 # Copyright (C) 2004 Thomas Kuehne | |
3 # | |
4 # This program is free software; you can redistribute it and/or modify | |
5 # it under the terms of the GNU General Public License as published by | |
6 # the Free Software Foundation; either version 2 of the License, or | |
7 # (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
15 # along with this program; if not, write to the Free Software | |
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
17 # | |
0 | 18 |
46 | 19 # dir: temp objects will be placed there |
32 | 20 ifndef OBJ_DIR |
0 | 21 OBJ_DIR = obj |
32 | 22 endif |
23 | |
46 | 24 # file: append compiler messages and runtime assertions |
83 | 25 # NOTE: this has to be an absolut path (required for some complex.mak files) |
32 | 26 ifndef LOG |
46 | 27 LOG = $(PWD)/log.txt |
32 | 28 endif |
0 | 29 |
46 | 30 # executeable: the compiler |
0 | 31 ifndef DMD |
32 DMD = dmd | |
33 endif | |
34 | |
46 | 35 # executeable: a GNU findutils compatible find (e.g.: find path -regex "?\\.*something") |
0 | 36 ifndef FIND |
37 FIND = find | |
38 endif | |
39 | |
46 | 40 # executeable: remove zero or more files (e.g.: rm -f a b c) |
0 | 41 ifndef RM |
46 | 42 RM = rm -f |
0 | 43 endif |
44 | |
46 | 45 # executeable: change to a given dir (e.g. cd some/other/dir) |
46 ifndef CD | |
47 CD = cd | |
48 endif | |
49 | |
50 # executeable: display a message test (e.g. echo "something to say) | |
0 | 51 ifndef ECHO |
52 ECHO = echo | |
53 endif | |
54 | |
46 | 55 # executeable: update the timestamp of an existing file or create a new empty file |
0 | 56 ifndef TOUCH |
57 TOUCH = touch | |
58 endif | |
59 | |
46 | 60 ############################################################################### |
61 ############################################################################### | |
62 # | |
63 # nothing to customize below | |
64 # | |
65 ############################################################################### | |
66 ############################################################################### | |
6 | 67 |
83 | 68 # tools |
69 return__ = ./return__ | |
70 ifeq__ = ./ifeq__ | |
71 extract__ = ./extract__ | |
72 | |
72 | 73 # settings |
0 | 74 to_log = >> $(LOG) 2>&1 |
75 ext_run = exe | |
76 ext_norun = bin | |
77 ext_nocompile = no | |
78 ext_compile = o | |
79 ext_source = d | |
6 | 80 ext_source_html = html |
46 | 81 complex_todo = complex.mak |
82 complex_done = complex.done | |
85
659bb018c489
1) changed "?DSTRESS_FLAGS?" to "__DSTRESS_DFLAGS__" in order to cope with botched shells
thomask
parents:
83
diff
changeset
|
83 flag_pattern = __DSTRESS_DFLAGS__ |
0 | 84 |
72 | 85 |
86 .PHONY: all basic_tools compile nocompile run norun complex clean distclean clean_log log | |
46 | 87 # |
88 # test everything | |
89 # | |
90 all : Makefile compile nocompile run norun complex | |
6 | 91 |
46 | 92 # |
72 | 93 # the tools |
94 # | |
83 | 95 $(return__) : return__.c Makefile |
96 $(CC) $(CFLAGS) $< -o $@ | |
97 | |
98 $(ifeq__) : ifeq__.c Makefile | |
72 | 99 $(CC) $(CFLAGS) $< -o $@ |
100 | |
83 | 101 $(extract__) : extract__.c Makefile |
72 | 102 $(CC) $(CFLAGS) $< -o $@ |
103 | |
83 | 104 basic_tools : $(ifeq__) $(return__) $(extract__) |
72 | 105 |
83 | 106 |
72 | 107 # |
46 | 108 # include complex test cases |
109 # | |
110 complex_makefiles = $(sort $(shell $(FIND) complex -regex ".*$(complex_todo)")) | |
111 include $(complex_makefiles) | |
6 | 112 |
83 | 113 # |
114 # extract potential compiling flags from the test case sources | |
115 # | |
116 define extract_z_flags | |
117 $(eval z_flags = $(shell $(extract__) $(flag_pattern) < $<)) | |
118 endef | |
119 | |
46 | 120 # |
121 # target should fail to compile | |
122 # | |
41
84e813a3e99b
fixed Makefile so that an edited makefile triggers a rebuild of outdated targets
thomask
parents:
32
diff
changeset
|
123 nocompile : Makefile $(sort $(subst .$(ext_source),.$(ext_nocompile),$(shell $(FIND) nocompile -regex ".*\\.$(ext_source)" ) ) $(subst .$(ext_source_html),.$(ext_nocompile),$(shell $(FIND) nocompile -regex ".*\\.$(ext_source_html)" ) ) ) |
17 | 124 |
75 | 125 define analyse_nocompile |
72 | 126 @if $(ifeq__) $(z_return) 0 ; then \ |
46 | 127 $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
128 else \ | |
72 | 129 if $(ifeq__) $(z_return) 256 ; then \ |
130 $(ECHO) "XFAIL: $(z_name)"; $(TOUCH) $@; \ | |
131 else \ | |
75 | 132 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
72 | 133 fi \ |
46 | 134 fi |
75 | 135 endef |
136 | |
137 %.$(ext_nocompile) : %.$(ext_source) basic_tools | |
138 $(eval z_name = $(subst .$(ext_nocompile),,$@)) | |
83 | 139 $(extract_z_flags) |
92 | 140 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) $(z_flags) -c -od$(OBJ_DIR) $< $(to_log)")) |
75 | 141 $(analyse_nocompile) |
142 | |
143 %.$(ext_nocompile) : %.$(ext_source_html) basic_tools | |
144 $(eval z_name = $(subst .$(ext_nocompile),,$@)) | |
83 | 145 $(extract_z_flags) |
92 | 146 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) $(z_flags) -c -od$(OBJ_DIR) $< $(to_log)")) |
75 | 147 $(analyse_nocompile) |
32 | 148 |
46 | 149 # |
150 # target should compile (excludes linking) | |
151 # | |
41
84e813a3e99b
fixed Makefile so that an edited makefile triggers a rebuild of outdated targets
thomask
parents:
32
diff
changeset
|
152 compile : Makefile $(sort $(subst .$(ext_source),.$(ext_compile),$(shell $(FIND) compile -regex ".*\\.$(ext_source)" ) ) $(subst .$(ext_source_html),.$(ext_compile),$(shell $(FIND) compile -regex ".*\\.$(ext_source_html)" ) ) ) |
0 | 153 |
75 | 154 define analyse_compile |
72 | 155 @if $(ifeq__) $(z_return) 0 ; then \ |
156 $(ECHO) "PASS: $(z_name)"; \ | |
46 | 157 else \ |
72 | 158 if $(ifeq__) $(z_return) 256 ; then \ |
159 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ | |
160 else \ | |
75 | 161 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
72 | 162 fi \ |
46 | 163 fi |
75 | 164 endef |
165 | |
166 %.$(ext_compile) : %.$(ext_source) basic_tools | |
167 $(eval z_name = $(subst .$(ext_compile),,$@)) | |
83 | 168 $(extract_z_flags) |
169 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) $(z_flags) -c -of$@ $< $(to_log)")) | |
75 | 170 $(analyse_compile) |
171 | |
0 | 172 |
72 | 173 %.$(ext_compile) : %.$(ext_source_html) basic_tools |
46 | 174 $(eval z_name = $(subst .$(ext_compile),,$@)) |
83 | 175 $(extract_z_flags) |
176 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) $(z_flags) -c -of$@ $< $(to_log)")) | |
75 | 177 $(analyse_compile) |
6 | 178 |
46 | 179 # |
180 # target should compile, link and run | |
181 # | |
41
84e813a3e99b
fixed Makefile so that an edited makefile triggers a rebuild of outdated targets
thomask
parents:
32
diff
changeset
|
182 run : Makefile $(sort $(subst .$(ext_source),.$(ext_run),$(shell $(FIND) run -regex ".*\\.$(ext_source)" ) ) $(subst .$(ext_source_html),.$(ext_run),$(shell $(FIND) run -regex ".*\\.$(ext_source_html)" ) ) ) |
0 | 183 |
75 | 184 define analyse_run |
72 | 185 @if $(ifeq__) $(z_return) 0 ; then \ |
80 | 186 $(eval z_return2 = $(shell $(return__) "./$@ $(to_log)")) \ |
187 if $(ifeq__) $(z_return2) 0 ; then \ | |
46 | 188 $(ECHO) "PASS: $(z_name)"; \ |
189 else \ | |
80 | 190 if $(ifeq__) $(z_return2) 256 ; then \ |
191 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ | |
192 else \ | |
193 $(ECHO) "ERROR: $(z_name) [run: $(z_return2)]"; $(RM) $@; \ | |
194 fi \ | |
46 | 195 fi \ |
196 else \ | |
72 | 197 if $(ifeq__) $(z_return) 256 ; then \ |
198 $(ECHO) "FAIL: $(z_name) (compiling error)"; \ | |
199 else \ | |
75 | 200 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; \ |
72 | 201 fi \ |
46 | 202 fi |
75 | 203 endef |
46 | 204 |
75 | 205 %.$(ext_run) : %.$(ext_source) basic_tools |
72 | 206 $(eval z_name = $(subst .$(ext_run),,$@)) |
83 | 207 $(extract_z_flags) |
208 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) $(z_flags) -od$(OBJ_DIR) -of$@ $< $(to_log)")) | |
75 | 209 $(analyse_run) |
0 | 210 |
72 | 211 %.$(ext_run) : %.$(ext_source_html) basic_tools |
63 | 212 $(eval z_name = $(subst .$(ext_run),,$@)) |
83 | 213 $(extract_z_flags) |
214 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) $(z_flags) -od$(OBJ_DIR) -of$@ $< $(to_log)")) | |
75 | 215 $(analyse_run) |
6 | 216 |
46 | 217 # |
218 # target should compile and link but fail to run | |
219 # | |
41
84e813a3e99b
fixed Makefile so that an edited makefile triggers a rebuild of outdated targets
thomask
parents:
32
diff
changeset
|
220 norun : Makefile $(sort $(subst .$(ext_source),.$(ext_norun),$(shell $(FIND) norun -regex ".*\\.$(ext_source)" ) ) $(subst .$(ext_source_html),.$(ext_norun),$(shell $(FIND) norun -regex ".*\\.$(ext_source_html)" ) ) ) |
0 | 221 |
75 | 222 define analyse_norun |
72 | 223 @if $(ifeq__) $(z_return) 0; then \ |
224 if ./$@ $(to_log); \ | |
58 | 225 then $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
46 | 226 else \ |
72 | 227 $(ECHO) "XFAIL: $(z_name)"; \ |
46 | 228 fi \ |
229 else \ | |
72 | 230 if $(ifeq__) $(z_return) 256 ; then \ |
231 $(ECHO) "FAIL: $(z_name) (compiling error)"; $(RM) $@; \ | |
232 else \ | |
75 | 233 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; \ |
72 | 234 fi \ |
46 | 235 fi |
75 | 236 endef |
237 | |
238 %.$(ext_norun) : %.$(ext_source) basic_tools | |
239 $(eval z_name = $(subst .$(ext_norun),,$@)) | |
83 | 240 $(extract_z_flags) |
241 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) $(z_flags) -od$(OBJ_DIR) -of$@ $< $(to_log)")) | |
75 | 242 $(analyse_norun) |
0 | 243 |
72 | 244 %.$(ext_norun) : %.$(ext_source_html) Makefile |
46 | 245 $(eval z_name = $(subst .$(ext_norun),,$@)) |
83 | 246 $(extract_z_flags) |
247 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) $(z_flags) -od$(OBJ_DIR) -of$@ $< $(to_log)")) | |
75 | 248 $(analyse_norun) |
249 | |
46 | 250 |
251 # | |
252 # run all complex test cases | |
253 # | |
254 complex : $(sort $(subst $(complex_todo),$(complex_done),$(complex_makefiles))) | |
6 | 255 |
32 | 256 |
17 | 257 log : distclean all |
32 | 258 |
46 | 259 # |
260 # | |
261 # | |
17 | 262 distclean : clean_log clean |
83 | 263 $(RM) $(shell $(FIND) . -regex ".*~") $(shell $(FIND) . -regex "\\..*\\.swp") |
264 $(RM) return__ ifeq__ extract__ www/*.class | |
6 | 265 |
46 | 266 # |
267 # remove compiler and assertion messages | |
268 # | |
0 | 269 clean_log : |
270 $(RM) $(LOG) | |
271 | |
46 | 272 # |
273 # remove targets and all temp objects | |
274 # | |
275 clean : $(sort $(subst $(complex_todo),clean,$(complex_makefiles))) | |
276 $(RM) $(OBJ_DIR)/?*.?* | |
277 $(RM) run/?*.$(ext_run) norun/?*.$(ext_norun) compile/?*.$(ext_compile) nocompile/?*.$(ext_nocompile) | |
83 | 278 |
279 # the empty line above has to remain, otherwise some weired problems can arise |