Mercurial > projects > dstress
annotate Makefile @ 503:3205f4fe859c
sort lists on all OSs equally
author | thomask |
---|---|
date | Tue, 10 May 2005 23:40:22 +0000 |
parents | 03a5d1fe1283 |
children | 924f45bc62e9 |
rev | line source |
---|---|
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
1 # $HeadURL$ |
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 |
6 # Copyright (C) 2004, 2005 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 |
190 | 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 | |
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__ | |
251 | 86 dstress__ := ./dstress__ |
490 | 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 |
441 | 102 .PHONY: all version basic_tools compile nocompile run norun complex clean distclean clean_log |
190 | 103 |
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 # | |
251 | 157 nocompile : $(dstress__) |
158 rm -f nocompile/*.o nocompile/*.$(ext_nocompile) | |
503 | 159 find nocompile -maxdepth 1 -name "?*.?*" | grep "." | sort --ignore-case | xargs -n 1 echo "$(dstress__) nocompile" > nocompile.sh |
251 | 160 chmod +x nocompile.sh |
161 ./nocompile.sh 2>> $(LOG) | |
17 | 162 |
251 | 163 # used in some complex test cases |
75 | 164 define analyse_nocompile |
72 | 165 @if $(ifeq__) $(z_return) 0 ; then \ |
46 | 166 $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
167 else \ | |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
168 if $(CAT) $(z_log) | $(GREP) ; then \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
169 $(ECHO) "ERROR: $(z_name) [Internal compiler error]"; $(RM) $@; \ |
72 | 170 else \ |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
171 if $(ifeq__) $(z_return) 256 ; then \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
172 $(ECHO) "XFAIL: $(z_name)"; $(TOUCH) $@; \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
173 else \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
174 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
175 fi \ |
72 | 176 fi \ |
46 | 177 fi |
75 | 178 endef |
179 | |
46 | 180 # |
181 # target should compile (excludes linking) | |
182 # | |
251 | 183 compile : $(dstress__) |
184 rm -f compile/*.o compile/*.$(ext_compile) | |
503 | 185 find compile -maxdepth 1 -name "?*.?*" | grep "." | sort --ignore-case | xargs -n 1 echo "$(dstress__) compile" > compile.sh |
251 | 186 chmod +x compile.sh |
187 ./compile.sh 2>> $(LOG) | |
0 | 188 |
251 | 189 # used in some complex test cases |
75 | 190 define analyse_compile |
72 | 191 @if $(ifeq__) $(z_return) 0 ; then \ |
217 | 192 $(ECHO) "PASS: $(z_name)"; $(TOUCH) $@; \ |
46 | 193 else \ |
72 | 194 if $(ifeq__) $(z_return) 256 ; then \ |
195 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ | |
196 else \ | |
75 | 197 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
72 | 198 fi \ |
46 | 199 fi |
75 | 200 endef |
201 | |
46 | 202 # |
203 # target should compile, link and run | |
204 # | |
251 | 205 run : $(dstress__) |
206 rm -f run/*.exe run/*.$(ext_run) | |
503 | 207 find run -maxdepth 1 -name "?*.?*" | grep "." | sort --ignore-case | xargs -n 1 echo "$(dstress__) run" > run.sh |
251 | 208 chmod +x run.sh |
209 ./run.sh 2>> $(LOG) | |
0 | 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 \ | |
46 | 216 $(ECHO) "PASS: $(z_name)"; \ |
217 else \ | |
80 | 218 if $(ifeq__) $(z_return2) 256 ; then \ |
219 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ | |
220 else \ | |
221 $(ECHO) "ERROR: $(z_name) [run: $(z_return2)]"; $(RM) $@; \ | |
222 fi \ | |
46 | 223 fi \ |
224 else \ | |
72 | 225 if $(ifeq__) $(z_return) 256 ; then \ |
226 $(ECHO) "FAIL: $(z_name) (compiling error)"; \ | |
227 else \ | |
75 | 228 $(ECHO) "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 # | |
251 | 270 norun : $(dstress__) |
271 rm -f norun/*.exe norun/*.$(ext_norun) | |
503 | 272 find norun -maxdepth 1 -name "?*.?*" | grep "." | sort --ignore-case | xargs -n 1 echo "$(dstress__) norun" > norun.sh |
251 | 273 chmod +x norun.sh |
274 ./norun.sh 2>> $(LOG) | |
0 | 275 |
251 | 276 # used in some complex test cases |
75 | 277 define analyse_norun |
72 | 278 @if $(ifeq__) $(z_return) 0; then \ |
279 if ./$@ $(to_log); \ | |
58 | 280 then $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
46 | 281 else \ |
72 | 282 $(ECHO) "XFAIL: $(z_name)"; \ |
46 | 283 fi \ |
284 else \ | |
72 | 285 if $(ifeq__) $(z_return) 256 ; then \ |
286 $(ECHO) "FAIL: $(z_name) (compiling error)"; $(RM) $@; \ | |
287 else \ | |
75 | 288 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; \ |
72 | 289 fi \ |
46 | 290 fi |
75 | 291 endef |
292 | |
46 | 293 # |
294 # run all complex test cases | |
295 # | |
251 | 296 complex : basic_tools $(sort $(subst $(complex_todo),$(complex_done),$(complex_makefiles))) |
32 | 297 |
46 | 298 # |
299 # | |
300 # | |
17 | 301 distclean : clean_log clean |
251 | 302 $(RM) $(shell $(FIND) . -regex ".*~") $(shell $(FIND) . -regex "\\..*\\.swp") $(shell $(FIND) . -regex "#.*#") |
490 | 303 $(RM) $(crashRun__) $(return__) $(ifeq__) $(extract__) $(dstress__) www/*.class |
6 | 304 |
46 | 305 # |
306 # remove compiler and assertion messages | |
307 # | |
0 | 308 clean_log : |
309 $(RM) $(LOG) | |
310 | |
46 | 311 # |
312 # remove targets and all temp objects | |
313 # | |
314 clean : $(sort $(subst $(complex_todo),clean,$(complex_makefiles))) | |
145
553c8aaa0982
added support for detecting segfaults with pseudo return code 1
thomask
parents:
109
diff
changeset
|
315 $(RM) $(OBJ_DIR)/?*.?* nocompile/?*.$(ext_log) |
46 | 316 $(RM) run/?*.$(ext_run) norun/?*.$(ext_norun) compile/?*.$(ext_compile) nocompile/?*.$(ext_nocompile) |
251 | 317 $(RM) run.sh norun.sh compile.sh nocompile.sh |
83 | 318 |
319 # the empty line above has to remain, otherwise some weired problems can arise |