Mercurial > projects > dstress
annotate Makefile @ 971:8da09834526d
* Valgrind support is now part of dstress.c instead of crashRun.c
* fixed parallel build of test cases with multiple object files
author | thomask |
---|---|
date | Thu, 20 Apr 2006 08:50:01 +0000 |
parents | 752d78bbb899 |
children | 7269c8972179 |
rev | line source |
---|---|
735 | 1 # $HeadURL$ |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
2 # $Date$ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
3 # $Author$ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
4 # |
239 | 5 # GnuMakefile for DStress http://dstress.kuehne.cn/www/dstress.html |
882 | 6 # Copyright (C) 2004, 2005, 2006 Thomas Kuehne |
46 | 7 # |
8 # This program is free software; you can redistribute it and/or modify | |
9 # it under the terms of the GNU General Public License as published by | |
10 # the Free Software Foundation; either version 2 of the License, or | |
11 # (at your option) any later version. | |
12 # | |
13 # This program is distributed in the hope that it will be useful, | |
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 # GNU General Public License for more details. | |
17 # | |
18 # You should have received a copy of the GNU General Public License | |
19 # along with this program; if not, write to the Free Software | |
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 # | |
0 | 22 |
46 | 23 # dir: temp objects will be placed there |
32 | 24 ifndef OBJ_DIR |
190 | 25 OBJ_DIR := obj |
32 | 26 endif |
27 | |
46 | 28 # file: append compiler messages and runtime assertions |
83 | 29 # NOTE: this has to be an absolut path (required for some complex.mak files) |
32 | 30 ifndef LOG |
190 | 31 LOG := $(PWD)/log.txt |
32 | 32 endif |
0 | 33 |
46 | 34 # executeable: the compiler |
0 | 35 ifndef DMD |
190 | 36 DMD := dmd |
0 | 37 endif |
38 | |
46 | 39 # executeable: a GNU findutils compatible find (e.g.: find path -regex "?\\.*something") |
0 | 40 ifndef FIND |
190 | 41 FIND := find |
0 | 42 endif |
43 | |
46 | 44 # executeable: remove zero or more files (e.g.: rm -f a b c) |
0 | 45 ifndef RM |
936
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
46 RM := rm -f -- |
0 | 47 endif |
48 | |
46 | 49 # executeable: change to a given dir (e.g. cd some/other/dir) |
50 ifndef CD | |
190 | 51 CD := cd |
46 | 52 endif |
53 | |
716 | 54 # executeable: display a message test (e.g. echo "something to say") |
0 | 55 ifndef ECHO |
190 | 56 ECHO := echo |
0 | 57 endif |
58 | |
46 | 59 # executeable: update the timestamp of an existing file or create a new empty file |
0 | 60 ifndef TOUCH |
190 | 61 TOUCH := touch |
0 | 62 endif |
63 | |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
64 # executeable: detect if stdin contains "Internal error" (dmd) or "gcc.gnu.org/bugs" (gcd) |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
65 ifndef GREP |
190 | 66 GREP := grep -s '\(Internal error\)\|\(gcc.gnu.org/bugs\)' > /dev/null 2>&1 |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
67 endif |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
68 |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
69 # executeable: used to concat files |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
70 ifndef CAT |
190 | 71 CAT := cat |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
72 endif |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
73 |
46 | 74 ############################################################################### |
75 ############################################################################### | |
76 # | |
77 # nothing to customize below | |
78 # | |
79 ############################################################################### | |
80 ############################################################################### | |
6 | 81 |
83 | 82 # tools |
969 | 83 return__ := $(PWD)/return__ |
190 | 84 ifeq__ := ./ifeq__ |
85 extract__ := ./extract__ | |
639 | 86 dstress__ := ./dstress |
87 crashRun__ := ./crashRun | |
83 | 88 |
72 | 89 # settings |
190 | 90 to_log := >> $(LOG) 2>&1 |
91 ext_run := exe | |
92 ext_norun := bin | |
93 ext_nocompile := no | |
94 ext_compile := o | |
95 ext_source := d | |
96 ext_source_html := html | |
97 ext_log := log | |
98 complex_todo := complex.mak | |
99 complex_done := complex.done | |
100 flag_pattern := __DSTRESS_DFLAGS__ | |
0 | 101 |
605 | 102 .PHONY:: all version basic_tools compile nocompile run norun complex clean distclean clean_log |
190 | 103 |
755
fb70ca0d80ba
updated resutls of DMD-0.093 - 0.101, 0.104, 0.121, 0.140
thomask
parents:
735
diff
changeset
|
104 .SUFFIXES:: $(ext_run) $(ext_norun) $(ext_nocompile) $(ext_compile) |
46 | 105 # |
106 # test everything | |
107 # | |
441 | 108 all : Makefile version compile nocompile run norun complex |
6 | 109 |
46 | 110 # |
72 | 111 # the tools |
112 # | |
971
8da09834526d
* Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents:
969
diff
changeset
|
113 % : %.c Makefile |
72 | 114 $(CC) $(CFLAGS) $< -o $@ |
115 | |
490 | 116 $(dstress__) : dstress.c $(crashRun__) Makefile |
969 | 117 $(CC) $(CFLAGS) -DUSE_VALGRIND $< -o $@ |
251 | 118 |
119 basic_tools : $(ifeq__) $(return__) $(extract__) $(dstress__) | |
441 | 120 |
121 # | |
122 # kludge to get version information from DMD and GDC's dmd wraper | |
123 # | |
124 version: | |
125 @$(ECHO) ">>>> VERSION <<<<" | |
494 | 126 @date +"%a, %e %b %Y %T %z" |
127 @uname -s -m -r | |
441 | 128 -@$(DMD) |
129 -@$(DMD) --version version_dummy.d | |
130 @$(ECHO) "<<<< VERSION >>>>" | |
83 | 131 |
72 | 132 # |
46 | 133 # include complex test cases |
134 # | |
190 | 135 complex_makefiles := $(sort $(shell $(FIND) complex -regex ".*$(complex_todo)")) |
46 | 136 include $(complex_makefiles) |
6 | 137 |
83 | 138 # |
139 # extract potential compiling flags from the test case sources | |
140 # | |
141 define extract_z_flags | |
142 $(eval z_flags = $(shell $(extract__) $(flag_pattern) < $<)) | |
143 endef | |
144 | |
46 | 145 # |
146 # target should fail to compile | |
147 # | |
529 | 148 nocompile : $(dstress__) nocompile_clean |
735 | 149 find nocompile -type f | grep -v ".svn" | sort --ignore-case | xargs -n 1 echo "$(dstress__) torture-nocompile" > nocompile.sh |
251 | 150 chmod +x nocompile.sh |
151 ./nocompile.sh 2>> $(LOG) | |
17 | 152 |
529 | 153 nocompile_clean : |
154 $(eval z_rm = $(shell find nocompile -type f -name "*\\.o" | grep -v ".svn")) | |
936
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
155 $(RM) $(z_rm) |
529 | 156 |
251 | 157 # used in some complex test cases |
75 | 158 define analyse_nocompile |
72 | 159 @if $(ifeq__) $(z_return) 0 ; then \ |
882 | 160 $(ECHO) "Torture-Sub-1/31-XPASS: $(z_name)"; $(RM) $@; \ |
46 | 161 else \ |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
162 if $(CAT) $(z_log) | $(GREP) ; then \ |
882 | 163 $(ECHO) "Torture-Sub-1/31-ERROR: $(z_name) [Internal compiler error]"; $(RM) $@; \ |
72 | 164 else \ |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
165 if $(ifeq__) $(z_return) 256 ; then \ |
882 | 166 $(ECHO) "Torture-Sub-1/31-XFAIL: $(z_name)"; $(TOUCH) $@; \ |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
167 else \ |
882 | 168 $(ECHO) "Torture-Sub-1/31-ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
169 fi \ |
72 | 170 fi \ |
46 | 171 fi |
75 | 172 endef |
173 | |
46 | 174 # |
175 # target should compile (excludes linking) | |
176 # | |
529 | 177 compile : $(dstress__) compile_clean |
735 | 178 find compile -type f | grep -v ".svn" | sort --ignore-case | xargs -n 1 echo "$(dstress__) torture-compile" > compile.sh |
251 | 179 chmod +x compile.sh |
180 ./compile.sh 2>> $(LOG) | |
0 | 181 |
529 | 182 compile_clean : |
183 $(eval z_rm = $(shell find compile -type f -name "*\\.o" | grep -v ".svn")) | |
936
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
184 $(RM) $(z_rm) |
529 | 185 |
251 | 186 # used in some complex test cases |
75 | 187 define analyse_compile |
72 | 188 @if $(ifeq__) $(z_return) 0 ; then \ |
882 | 189 $(ECHO) "Torture-Sub-1/31-PASS: $(z_name)"; $(TOUCH) $@; \ |
46 | 190 else \ |
72 | 191 if $(ifeq__) $(z_return) 256 ; then \ |
882 | 192 $(ECHO) "Torture-Sub-1/31-FAIL: $(z_name)"; $(RM) $@; \ |
72 | 193 else \ |
882 | 194 $(ECHO) "Torture-Sub-1/31-ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
72 | 195 fi \ |
46 | 196 fi |
75 | 197 endef |
198 | |
46 | 199 # |
200 # target should compile, link and run | |
201 # | |
529 | 202 run : $(dstress__) run_clean |
735 | 203 find run -type f | grep -v ".svn" | sort --ignore-case | xargs -n 1 echo "$(dstress__) torture-run" > run.sh |
251 | 204 chmod +x run.sh |
205 ./run.sh 2>> $(LOG) | |
0 | 206 |
529 | 207 run_clean : |
208 $(eval z_rm = $(shell find run -type f -name "*\\.exe" | grep -v ".svn")) | |
209 $(RM) $(z_rm) | |
210 | |
251 | 211 # used in some complex testcases |
75 | 212 define analyse_run |
72 | 213 @if $(ifeq__) $(z_return) 0 ; then \ |
80 | 214 $(eval z_return2 = $(shell $(return__) "./$@ $(to_log)")) \ |
215 if $(ifeq__) $(z_return2) 0 ; then \ | |
882 | 216 $(ECHO) "Torture-Sub-1/31-PASS: $(z_name)"; \ |
46 | 217 else \ |
80 | 218 if $(ifeq__) $(z_return2) 256 ; then \ |
882 | 219 $(ECHO) "Torture-Sub-1/31-FAIL: $(z_name)"; $(RM) $@; \ |
80 | 220 else \ |
882 | 221 $(ECHO) "Torture-Sub-1/31-ERROR: $(z_name) [run: $(z_return2)]"; $(RM) $@; \ |
80 | 222 fi \ |
46 | 223 fi \ |
224 else \ | |
72 | 225 if $(ifeq__) $(z_return) 256 ; then \ |
882 | 226 $(ECHO) "Torture-Sub-1/31-FAIL: $(z_name) (compiling error)"; \ |
72 | 227 else \ |
882 | 228 $(ECHO) "Torture-Sub-1/31-ERROR: $(z_name) [$(z_return)]"; \ |
72 | 229 fi \ |
46 | 230 fi |
75 | 231 endef |
46 | 232 |
233 # | |
108 | 234 # target should compile, link and run |
235 # (used for Makefile diagnosis) | |
236 # | |
237 %.diagnose.$(ext_run) : %.$(ext_source) basic_tools | |
238 # destination: $@ | |
239 # source: $< | |
109
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
240 $(eval y_tmp = OK) |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
241 # eval: $(y_tmp) |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
242 # shell: |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
243 @$(ECHO) $(shell $(ECHO) "OK") |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
244 $(eval y_tmp = $(shell $(ECHO) "OK")) |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
245 # eval.shell: $(y_tmp) |
108 | 246 $(eval z_name = $(subst .diagnose.$(ext_run),,$@)) |
247 # name: $(z_name) | |
248 # extract__: $(extract__) | |
249 # extract__.cmd: $(extract__) $(flag_pattern) < $< | |
250 $(extract_z_flags) | |
251 # extract__.result: $(z_flags) | |
252 # ifeq__: $(ifeq__) | |
253 # continue if ifeq__ works | |
254 $(ifeq__) someString someString | |
255 # return__: $(return__) | |
256 # dmd: $(DMD) | |
257 $(eval y_tmp = $(shell $(return__) "$(ifeq__) 1 1")) | |
258 # return__.return_code_0: $(y_tmp) (expect=0) | |
259 $(eval y_tmp = $(shell $(return__) "$(DMD) > /dev/null")) | |
260 # return__.return_code_1: $(y_tmp) (expect=256) | |
261 # dmd.cmd: $(DMD) $(DFLAGS) $(z_flags) -od$(OBJ_DIR) -of$@ $< $(to_log) | |
262 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) $(z_flags) -od$(OBJ_DIR) -of$@ $< $(to_log)")) | |
263 # dmd.return: $(z_return) | |
264 # for analyse_run diagnosis: '@if' -> 'if' in 'define analyse_run' (line 185) | |
265 $(analyse_run) | |
266 | |
267 # | |
46 | 268 # target should compile and link but fail to run |
269 # | |
529 | 270 norun : $(dstress__) norun_clean |
735 | 271 find norun -type f | grep -v ".svn" | sort --ignore-case | xargs -n 1 echo "$(dstress__) torture-norun" > norun.sh |
251 | 272 chmod +x norun.sh |
273 ./norun.sh 2>> $(LOG) | |
0 | 274 |
529 | 275 norun_clean : |
276 $(eval z_rm = $(shell find norun -type f -name "*\\.exe" | grep -v ".svn")) | |
277 $(RM) $(z_rm) | |
278 | |
251 | 279 # used in some complex test cases |
75 | 280 define analyse_norun |
72 | 281 @if $(ifeq__) $(z_return) 0; then \ |
282 if ./$@ $(to_log); \ | |
882 | 283 then $(ECHO) "Torture-Sub-1/31-XPASS: $(z_name)"; $(RM) $@; \ |
46 | 284 else \ |
882 | 285 $(ECHO) "Torture-Sub-1/31-XFAIL: $(z_name)"; \ |
46 | 286 fi \ |
287 else \ | |
72 | 288 if $(ifeq__) $(z_return) 256 ; then \ |
882 | 289 $(ECHO) "Torture-Sub-1/31-FAIL: $(z_name) (compiling error)"; $(RM) $@; \ |
72 | 290 else \ |
882 | 291 $(ECHO) "Torture-Sub-1/31-ERROR: $(z_name) [$(z_return)]"; \ |
72 | 292 fi \ |
46 | 293 fi |
75 | 294 endef |
295 | |
46 | 296 # |
297 # run all complex test cases | |
298 # | |
251 | 299 complex : basic_tools $(sort $(subst $(complex_todo),$(complex_done),$(complex_makefiles))) |
32 | 300 |
46 | 301 # |
302 # | |
303 # | |
17 | 304 distclean : clean_log clean |
708 | 305 $(RM) $(shell $(FIND) . -regex ".*~") |
306 $(RM) $(shell $(FIND) . -regex "\\..*\\.swp") | |
307 $(RM) $(shell $(FIND) . -regex "#.*#") | |
308 $(RM) $(shell $(FIND) . -regex ".*\\.map") | |
309 $(RM) $(shell $(FIND) . -regex ".*\\.bak") | |
490 | 310 $(RM) $(crashRun__) $(return__) $(ifeq__) $(extract__) $(dstress__) www/*.class |
6 | 311 |
46 | 312 # |
313 # remove compiler and assertion messages | |
314 # | |
0 | 315 clean_log : |
316 $(RM) $(LOG) | |
317 | |
46 | 318 # |
319 # remove targets and all temp objects | |
320 # | |
605 | 321 complex_clean : $(sort $(subst $(complex_todo),clean,$(complex_makefiles))) |
322 | |
939 | 323 clean :: complex_clean nocompile_clean compile_clean norun_clean run_clean |
936
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
324 $(RM) $(OBJ_DIR)/[A-E]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
325 $(RM) $(OBJ_DIR)/[F-J]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
326 $(RM) $(OBJ_DIR)/[K-O]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
327 $(RM) $(OBJ_DIR)/[P-T]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
328 $(RM) $(OBJ_DIR)/[U-Z]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
329 $(RM) $(OBJ_DIR)/[a-e]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
330 $(RM) $(OBJ_DIR)/[f-j]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
331 $(RM) $(OBJ_DIR)/[k-o]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
332 $(RM) $(OBJ_DIR)/[p-t]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
333 $(RM) $(OBJ_DIR)/[u-z]*.* |
971
8da09834526d
* Valgrind support is now part of dstress.c instead of crashRun.c
thomask
parents:
969
diff
changeset
|
334 $(RM) -rf $(OBJ_DIR)/* |
251 | 335 $(RM) run.sh norun.sh compile.sh nocompile.sh |
83 | 336 |
337 # the empty line above has to remain, otherwise some weired problems can arise |