Mercurial > projects > dstress
annotate Makefile @ 72:b0e95b878322
added segfault detection support
author | thomask |
---|---|
date | Wed, 27 Oct 2004 17:26:14 +0000 |
parents | 9ca076fc9ce9 |
children | edc279c4f7f9 |
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 |
25 # NOTE: this has to be an absolute file name, not a relative one (required by some complex test cases) | |
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 |
72 | 68 # settings |
0 | 69 to_log = >> $(LOG) 2>&1 |
70 ext_run = exe | |
46 | 71 ext_unittest_run = unittest.$(ext_run) |
0 | 72 ext_norun = bin |
73 ext_nocompile = no | |
46 | 74 ext_unittest_nocompile = unittest.$(ext_nocompile) |
0 | 75 ext_compile = o |
76 ext_source = d | |
6 | 77 ext_source_html = html |
46 | 78 complex_todo = complex.mak |
79 complex_done = complex.done | |
0 | 80 |
72 | 81 # tools |
82 return__ = ./return__ | |
83 ifeq__ = ./ifeq__ | |
84 | |
85 .PHONY: all basic_tools compile nocompile run norun complex clean distclean clean_log log | |
46 | 86 # |
87 # test everything | |
88 # | |
89 all : Makefile compile nocompile run norun complex | |
6 | 90 |
46 | 91 # |
72 | 92 # the tools |
93 # | |
94 return__ : return__.c | |
95 $(CC) $(CFLAGS) $< -o $@ | |
96 | |
97 ifeq__ : ifeq__.c | |
98 $(CC) $(CFLAGS) $< -o $@ | |
99 | |
100 basic_tools : Makefile $(ifeq__) $(return__) | |
101 | |
102 # | |
46 | 103 # include complex test cases |
104 # | |
105 complex_makefiles = $(sort $(shell $(FIND) complex -regex ".*$(complex_todo)")) | |
106 include $(complex_makefiles) | |
6 | 107 |
46 | 108 # |
109 # target should fail to compile | |
110 # | |
41
84e813a3e99b
fixed Makefile so that an edited makefile triggers a rebuild of outdated targets
thomask
parents:
32
diff
changeset
|
111 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 | 112 |
72 | 113 %.$(ext_nocompile) : %.$(ext_source) basic_tools |
46 | 114 $(eval z_name = $(subst .$(ext_nocompile),,$@)) |
72 | 115 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)")) |
116 @if $(ifeq__) $(z_return) 0 ; then \ | |
46 | 117 $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
118 else \ | |
72 | 119 if $(ifeq__) $(z_return) 256 ; then \ |
120 $(ECHO) "XFAIL: $(z_name)"; $(TOUCH) $@; \ | |
121 else \ | |
122 $(ECHO) "ERROR: $(z_name)"; $(RM) $@; \ | |
123 fi \ | |
46 | 124 fi |
17 | 125 |
72 | 126 %.$(ext_nocompile) : %.$(ext_source_html) basic_tools |
46 | 127 $(eval z_name = $(subst .$(ext_nocompile),,$@)) |
72 | 128 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)")) |
129 @if $(ifeq__) $(z_return) 0 ; then \ | |
46 | 130 $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
131 else \ | |
72 | 132 if $(ifeq__) $(z_return) 256 ; then \ |
133 $(ECHO) "XFAIL: $(z_name)"; $(TOUCH) $@; \ | |
134 else \ | |
135 $(ECHO) "ERROR: $(z_name)"; $(RM) $@; \ | |
136 fi \ | |
46 | 137 fi |
17 | 138 |
72 | 139 %.$(ext_unittest_nocompile) : %.$(ext_source) basic_tools |
46 | 140 $(eval z_name = $(subst .$(ext_unittest_nocompile),,$@)) |
72 | 141 $(eval z_return = $(shell $(return__) "$(DMD) -unittest $(DFLAGS) -c -of$@ $< $(to_log)")) |
142 @if $(ifeq__) $(z_return) 0 ; then \ | |
46 | 143 $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
144 else \ | |
72 | 145 if $(ifeq__) $(z_return) 256 ; then \ |
146 $(ECHO) "XFAIL: $(z_name)"; $(TOUCH) $@; \ | |
147 else \ | |
148 $(ECHO) "ERROR: $(z_name)"; $(RM) $@; \ | |
149 fi \ | |
46 | 150 fi |
32 | 151 |
46 | 152 # |
153 # target should compile (excludes linking) | |
154 # | |
41
84e813a3e99b
fixed Makefile so that an edited makefile triggers a rebuild of outdated targets
thomask
parents:
32
diff
changeset
|
155 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 | 156 |
72 | 157 %.$(ext_compile) : %.$(ext_source) basic_tools |
46 | 158 $(eval z_name = $(subst .$(ext_compile),,$@)) |
72 | 159 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)")) |
160 @if $(ifeq__) $(z_return) 0 ; then \ | |
161 $(ECHO) "PASS: $(z_name)"; \ | |
46 | 162 else \ |
72 | 163 if $(ifeq__) $(z_return) 256 ; then \ |
164 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ | |
165 else \ | |
166 $(ECHO) "ERROR: $(z_name)"; $(RM) $@; \ | |
167 fi \ | |
46 | 168 fi |
0 | 169 |
72 | 170 %.$(ext_compile) : %.$(ext_source_html) basic_tools |
46 | 171 $(eval z_name = $(subst .$(ext_compile),,$@)) |
72 | 172 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)")) |
173 @if $(ifeq__) $(z_return) 0 ; then \ | |
174 $(ECHO) "PASS: $(z_name)"; \ | |
46 | 175 else \ |
72 | 176 if $(ifeq__) $(z_return) 256 ; then \ |
177 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ | |
178 else \ | |
179 $(ECHO) "ERROR: $(z_name)"; $(RM) $@; \ | |
180 fi \ | |
46 | 181 fi |
6 | 182 |
46 | 183 # |
184 # target should compile, link and run | |
185 # | |
41
84e813a3e99b
fixed Makefile so that an edited makefile triggers a rebuild of outdated targets
thomask
parents:
32
diff
changeset
|
186 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 | 187 |
72 | 188 %.$(ext_run) : %.$(ext_source) basic_tools |
46 | 189 $(eval z_name = $(subst .$(ext_run),,$@)) |
72 | 190 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)")) |
191 @if $(ifeq__) $(z_return) 0 ; then \ | |
192 if ./$@ $(to_log); then \ | |
46 | 193 $(ECHO) "PASS: $(z_name)"; \ |
194 else \ | |
72 | 195 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ |
46 | 196 fi \ |
197 else \ | |
72 | 198 if $(ifeq__) $(z_return) 256 ; then \ |
199 $(ECHO) "FAIL: $(z_name) (compiling error)"; \ | |
200 else \ | |
201 $(ECHO) "ERROR: $(z_name)"; \ | |
202 fi \ | |
46 | 203 fi |
204 | |
72 | 205 %.$(ext_unittest_run) : %.$(ext_source) basic_tools |
206 $(eval z_name = $(subst .$(ext_run),,$@)) | |
207 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -unittest -od$(OBJ_DIR) -of$@ $< $(to_log)")) | |
208 @if $(ifeq__) $(z_return) 0 ; then \ | |
209 if ./$@ $(to_log); then \ | |
46 | 210 $(ECHO) "PASS: $(z_name)"; \ |
211 else \ | |
72 | 212 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ |
46 | 213 fi \ |
214 else \ | |
72 | 215 if $(ifeq__) $(z_return) 256 ; then \ |
216 $(ECHO) "FAIL: $(z_name) (compiling error)"; \ | |
217 else \ | |
218 $(ECHO) "ERROR: $(z_name)"; \ | |
219 fi \ | |
46 | 220 fi |
0 | 221 |
72 | 222 %.$(ext_run) : %.$(ext_source_html) basic_tools |
63 | 223 $(eval z_name = $(subst .$(ext_run),,$@)) |
72 | 224 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)")) |
225 @if $(ifeq__) $(z_return) 0 ; then \ | |
226 if ./$@ $(to_log); then \ | |
46 | 227 $(ECHO) "PASS: $(z_name)"; \ |
228 else \ | |
72 | 229 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ |
46 | 230 fi \ |
231 else \ | |
72 | 232 if $(ifeq__) $(z_return) 256 ; then \ |
233 $(ECHO) "FAIL: $(z_name) (compiling error)"; \ | |
234 else \ | |
235 $(ECHO) "ERROR: $(z_name)"; \ | |
236 fi \ | |
46 | 237 fi |
6 | 238 |
46 | 239 # |
240 # target should compile and link but fail to run | |
241 # | |
41
84e813a3e99b
fixed Makefile so that an edited makefile triggers a rebuild of outdated targets
thomask
parents:
32
diff
changeset
|
242 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 | 243 |
72 | 244 %.$(ext_norun) : %.$(ext_source) basic_tools |
46 | 245 $(eval z_name = $(subst .$(ext_norun),,$@)) |
72 | 246 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)")) |
247 @if $(ifeq__) $(z_return) 0; then \ | |
248 if ./$@ $(to_log); \ | |
58 | 249 then $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
46 | 250 else \ |
72 | 251 $(ECHO) "XFAIL: $(z_name)"; \ |
46 | 252 fi \ |
253 else \ | |
72 | 254 if $(ifeq__) $(z_return) 256 ; then \ |
255 $(ECHO) "FAIL: $(z_name) (compiling error)"; $(RM) $@; \ | |
256 else \ | |
257 $(ECHO) "ERROR: $(z_name)"; \ | |
258 fi \ | |
46 | 259 fi |
0 | 260 |
72 | 261 %.$(ext_norun) : %.$(ext_source_html) Makefile |
46 | 262 $(eval z_name = $(subst .$(ext_norun),,$@)) |
72 | 263 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)")) |
264 @if $(ifeq__) $(z_return) 0; then \ | |
265 if ./$@ $(to_log); \ | |
266 then $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ | |
46 | 267 else \ |
72 | 268 $(ECHO) "XFAIL: $(z_name)"; \ |
46 | 269 fi \ |
270 else \ | |
72 | 271 if $(ifeq__) $(z_return) 256 ; then \ |
272 $(ECHO) "FAIL: $(z_name) (compiling error)"; $(RM) $@; \ | |
273 else \ | |
274 $(ECHO) "ERROR: $(z_name)"; \ | |
275 fi \ | |
46 | 276 fi |
277 | |
278 # | |
279 # run all complex test cases | |
280 # | |
281 complex : $(sort $(subst $(complex_todo),$(complex_done),$(complex_makefiles))) | |
6 | 282 |
32 | 283 |
17 | 284 log : distclean all |
32 | 285 |
46 | 286 # |
287 # | |
288 # | |
17 | 289 distclean : clean_log clean |
72 | 290 $(RM) $(shell $(FIND) . -regex ".*~") |
6 | 291 |
46 | 292 # |
293 # remove compiler and assertion messages | |
294 # | |
0 | 295 clean_log : |
296 $(RM) $(LOG) | |
297 | |
72 | 298 #test.xx : |
299 # $(eval tempus=$(shell ./dstress_return "$(DMD) test.d -oftest.xx $(to_log)")) | |
300 # echo "$(tempus)" | |
301 | |
46 | 302 # |
303 # remove targets and all temp objects | |
304 # | |
305 clean : $(sort $(subst $(complex_todo),clean,$(complex_makefiles))) | |
306 $(RM) $(OBJ_DIR)/?*.?* | |
307 $(RM) run/?*.$(ext_run) norun/?*.$(ext_norun) compile/?*.$(ext_compile) nocompile/?*.$(ext_nocompile) |