Mercurial > projects > dstress
annotate Makefile @ 936:daeca9f37d08
adapeted "clean" target to the large number of files
author | thomask |
---|---|
date | Sun, 26 Mar 2006 12:39:49 +0000 |
parents | 534a591a0225 |
children | 38e8bc3a9a50 |
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 |
190 | 83 return__ := ./return__ |
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 # | |
83 | 113 $(return__) : return__.c Makefile |
114 $(CC) $(CFLAGS) $< -o $@ | |
115 | |
116 $(ifeq__) : ifeq__.c Makefile | |
72 | 117 $(CC) $(CFLAGS) $< -o $@ |
118 | |
83 | 119 $(extract__) : extract__.c Makefile |
72 | 120 $(CC) $(CFLAGS) $< -o $@ |
121 | |
490 | 122 $(dstress__) : dstress.c $(crashRun__) Makefile |
123 $(CC) $(CFLAGS) $< -o $@ | |
124 | |
125 $(crashRun__) : crashRun.c Makefile | |
251 | 126 $(CC) $(CFLAGS) $< -o $@ |
127 | |
128 basic_tools : $(ifeq__) $(return__) $(extract__) $(dstress__) | |
441 | 129 |
130 # | |
131 # kludge to get version information from DMD and GDC's dmd wraper | |
132 # | |
133 version: | |
134 @$(ECHO) ">>>> VERSION <<<<" | |
494 | 135 @date +"%a, %e %b %Y %T %z" |
136 @uname -s -m -r | |
441 | 137 -@$(DMD) |
138 -@$(DMD) --version version_dummy.d | |
139 @$(ECHO) "<<<< VERSION >>>>" | |
83 | 140 |
72 | 141 # |
46 | 142 # include complex test cases |
143 # | |
190 | 144 complex_makefiles := $(sort $(shell $(FIND) complex -regex ".*$(complex_todo)")) |
46 | 145 include $(complex_makefiles) |
6 | 146 |
83 | 147 # |
148 # extract potential compiling flags from the test case sources | |
149 # | |
150 define extract_z_flags | |
151 $(eval z_flags = $(shell $(extract__) $(flag_pattern) < $<)) | |
152 endef | |
153 | |
46 | 154 # |
155 # target should fail to compile | |
156 # | |
529 | 157 nocompile : $(dstress__) nocompile_clean |
735 | 158 find nocompile -type f | grep -v ".svn" | sort --ignore-case | xargs -n 1 echo "$(dstress__) torture-nocompile" > nocompile.sh |
251 | 159 chmod +x nocompile.sh |
160 ./nocompile.sh 2>> $(LOG) | |
17 | 161 |
529 | 162 nocompile_clean : |
163 $(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
|
164 $(RM) $(z_rm) |
529 | 165 |
251 | 166 # used in some complex test cases |
75 | 167 define analyse_nocompile |
72 | 168 @if $(ifeq__) $(z_return) 0 ; then \ |
882 | 169 $(ECHO) "Torture-Sub-1/31-XPASS: $(z_name)"; $(RM) $@; \ |
46 | 170 else \ |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
171 if $(CAT) $(z_log) | $(GREP) ; then \ |
882 | 172 $(ECHO) "Torture-Sub-1/31-ERROR: $(z_name) [Internal compiler error]"; $(RM) $@; \ |
72 | 173 else \ |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
174 if $(ifeq__) $(z_return) 256 ; then \ |
882 | 175 $(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
|
176 else \ |
882 | 177 $(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
|
178 fi \ |
72 | 179 fi \ |
46 | 180 fi |
75 | 181 endef |
182 | |
46 | 183 # |
184 # target should compile (excludes linking) | |
185 # | |
529 | 186 compile : $(dstress__) compile_clean |
735 | 187 find compile -type f | grep -v ".svn" | sort --ignore-case | xargs -n 1 echo "$(dstress__) torture-compile" > compile.sh |
251 | 188 chmod +x compile.sh |
189 ./compile.sh 2>> $(LOG) | |
0 | 190 |
529 | 191 compile_clean : |
192 $(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
|
193 $(RM) $(z_rm) |
529 | 194 |
251 | 195 # used in some complex test cases |
75 | 196 define analyse_compile |
72 | 197 @if $(ifeq__) $(z_return) 0 ; then \ |
882 | 198 $(ECHO) "Torture-Sub-1/31-PASS: $(z_name)"; $(TOUCH) $@; \ |
46 | 199 else \ |
72 | 200 if $(ifeq__) $(z_return) 256 ; then \ |
882 | 201 $(ECHO) "Torture-Sub-1/31-FAIL: $(z_name)"; $(RM) $@; \ |
72 | 202 else \ |
882 | 203 $(ECHO) "Torture-Sub-1/31-ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
72 | 204 fi \ |
46 | 205 fi |
75 | 206 endef |
207 | |
46 | 208 # |
209 # target should compile, link and run | |
210 # | |
529 | 211 run : $(dstress__) run_clean |
735 | 212 find run -type f | grep -v ".svn" | sort --ignore-case | xargs -n 1 echo "$(dstress__) torture-run" > run.sh |
251 | 213 chmod +x run.sh |
214 ./run.sh 2>> $(LOG) | |
0 | 215 |
529 | 216 run_clean : |
217 $(eval z_rm = $(shell find run -type f -name "*\\.exe" | grep -v ".svn")) | |
218 $(RM) $(z_rm) | |
219 | |
251 | 220 # used in some complex testcases |
75 | 221 define analyse_run |
72 | 222 @if $(ifeq__) $(z_return) 0 ; then \ |
80 | 223 $(eval z_return2 = $(shell $(return__) "./$@ $(to_log)")) \ |
224 if $(ifeq__) $(z_return2) 0 ; then \ | |
882 | 225 $(ECHO) "Torture-Sub-1/31-PASS: $(z_name)"; \ |
46 | 226 else \ |
80 | 227 if $(ifeq__) $(z_return2) 256 ; then \ |
882 | 228 $(ECHO) "Torture-Sub-1/31-FAIL: $(z_name)"; $(RM) $@; \ |
80 | 229 else \ |
882 | 230 $(ECHO) "Torture-Sub-1/31-ERROR: $(z_name) [run: $(z_return2)]"; $(RM) $@; \ |
80 | 231 fi \ |
46 | 232 fi \ |
233 else \ | |
72 | 234 if $(ifeq__) $(z_return) 256 ; then \ |
882 | 235 $(ECHO) "Torture-Sub-1/31-FAIL: $(z_name) (compiling error)"; \ |
72 | 236 else \ |
882 | 237 $(ECHO) "Torture-Sub-1/31-ERROR: $(z_name) [$(z_return)]"; \ |
72 | 238 fi \ |
46 | 239 fi |
75 | 240 endef |
46 | 241 |
242 # | |
108 | 243 # target should compile, link and run |
244 # (used for Makefile diagnosis) | |
245 # | |
246 %.diagnose.$(ext_run) : %.$(ext_source) basic_tools | |
247 # destination: $@ | |
248 # source: $< | |
109
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
249 $(eval y_tmp = OK) |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
250 # eval: $(y_tmp) |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
251 # shell: |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
252 @$(ECHO) $(shell $(ECHO) "OK") |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
253 $(eval y_tmp = $(shell $(ECHO) "OK")) |
0e5c059a7658
added diagnosis for GNUMake's $(eval ...), $(shell ...) and $(eval ... $(shell ...))
thomask
parents:
108
diff
changeset
|
254 # eval.shell: $(y_tmp) |
108 | 255 $(eval z_name = $(subst .diagnose.$(ext_run),,$@)) |
256 # name: $(z_name) | |
257 # extract__: $(extract__) | |
258 # extract__.cmd: $(extract__) $(flag_pattern) < $< | |
259 $(extract_z_flags) | |
260 # extract__.result: $(z_flags) | |
261 # ifeq__: $(ifeq__) | |
262 # continue if ifeq__ works | |
263 $(ifeq__) someString someString | |
264 # return__: $(return__) | |
265 # dmd: $(DMD) | |
266 $(eval y_tmp = $(shell $(return__) "$(ifeq__) 1 1")) | |
267 # return__.return_code_0: $(y_tmp) (expect=0) | |
268 $(eval y_tmp = $(shell $(return__) "$(DMD) > /dev/null")) | |
269 # return__.return_code_1: $(y_tmp) (expect=256) | |
270 # dmd.cmd: $(DMD) $(DFLAGS) $(z_flags) -od$(OBJ_DIR) -of$@ $< $(to_log) | |
271 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) $(z_flags) -od$(OBJ_DIR) -of$@ $< $(to_log)")) | |
272 # dmd.return: $(z_return) | |
273 # for analyse_run diagnosis: '@if' -> 'if' in 'define analyse_run' (line 185) | |
274 $(analyse_run) | |
275 | |
276 # | |
46 | 277 # target should compile and link but fail to run |
278 # | |
529 | 279 norun : $(dstress__) norun_clean |
735 | 280 find norun -type f | grep -v ".svn" | sort --ignore-case | xargs -n 1 echo "$(dstress__) torture-norun" > norun.sh |
251 | 281 chmod +x norun.sh |
282 ./norun.sh 2>> $(LOG) | |
0 | 283 |
529 | 284 norun_clean : |
285 $(eval z_rm = $(shell find norun -type f -name "*\\.exe" | grep -v ".svn")) | |
286 $(RM) $(z_rm) | |
287 | |
251 | 288 # used in some complex test cases |
75 | 289 define analyse_norun |
72 | 290 @if $(ifeq__) $(z_return) 0; then \ |
291 if ./$@ $(to_log); \ | |
882 | 292 then $(ECHO) "Torture-Sub-1/31-XPASS: $(z_name)"; $(RM) $@; \ |
46 | 293 else \ |
882 | 294 $(ECHO) "Torture-Sub-1/31-XFAIL: $(z_name)"; \ |
46 | 295 fi \ |
296 else \ | |
72 | 297 if $(ifeq__) $(z_return) 256 ; then \ |
882 | 298 $(ECHO) "Torture-Sub-1/31-FAIL: $(z_name) (compiling error)"; $(RM) $@; \ |
72 | 299 else \ |
882 | 300 $(ECHO) "Torture-Sub-1/31-ERROR: $(z_name) [$(z_return)]"; \ |
72 | 301 fi \ |
46 | 302 fi |
75 | 303 endef |
304 | |
46 | 305 # |
306 # run all complex test cases | |
307 # | |
251 | 308 complex : basic_tools $(sort $(subst $(complex_todo),$(complex_done),$(complex_makefiles))) |
32 | 309 |
46 | 310 # |
311 # | |
312 # | |
17 | 313 distclean : clean_log clean |
708 | 314 $(RM) $(shell $(FIND) . -regex ".*~") |
315 $(RM) $(shell $(FIND) . -regex "\\..*\\.swp") | |
316 $(RM) $(shell $(FIND) . -regex "#.*#") | |
317 $(RM) $(shell $(FIND) . -regex ".*\\.map") | |
318 $(RM) $(shell $(FIND) . -regex ".*\\.bak") | |
490 | 319 $(RM) $(crashRun__) $(return__) $(ifeq__) $(extract__) $(dstress__) www/*.class |
6 | 320 |
46 | 321 # |
322 # remove compiler and assertion messages | |
323 # | |
0 | 324 clean_log : |
325 $(RM) $(LOG) | |
326 | |
46 | 327 # |
328 # remove targets and all temp objects | |
329 # | |
605 | 330 complex_clean : $(sort $(subst $(complex_todo),clean,$(complex_makefiles))) |
331 | |
332 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
|
333 $(RM) $(OBJ_DIR)/[A-E]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
334 $(RM) $(OBJ_DIR)/[F-J]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
335 $(RM) $(OBJ_DIR)/[K-O]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
336 $(RM) $(OBJ_DIR)/[P-T]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
337 $(RM) $(OBJ_DIR)/[U-Z]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
338 $(RM) $(OBJ_DIR)/[a-e]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
339 $(RM) $(OBJ_DIR)/[f-j]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
340 $(RM) $(OBJ_DIR)/[k-o]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
341 $(RM) $(OBJ_DIR)/[p-t]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
342 $(RM) $(OBJ_DIR)/[u-z]*.* |
daeca9f37d08
adapeted "clean" target to the large number of files
thomask
parents:
882
diff
changeset
|
343 $(RM) $(OBJ_DIR)/?*.* |
251 | 344 $(RM) run.sh norun.sh compile.sh nocompile.sh |
83 | 345 |
346 # the empty line above has to remain, otherwise some weired problems can arise |