Mercurial > projects > dstress
annotate Makefile @ 75:edc279c4f7f9
makefile cleanup
author | thomask |
---|---|
date | Thu, 28 Oct 2004 06:07:57 +0000 |
parents | b0e95b878322 |
children | 72fa445c2fbb |
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 | |
71 ext_norun = bin | |
72 ext_nocompile = no | |
73 ext_compile = o | |
74 ext_source = d | |
6 | 75 ext_source_html = html |
46 | 76 complex_todo = complex.mak |
77 complex_done = complex.done | |
0 | 78 |
72 | 79 # tools |
80 return__ = ./return__ | |
81 ifeq__ = ./ifeq__ | |
82 | |
83 .PHONY: all basic_tools compile nocompile run norun complex clean distclean clean_log log | |
46 | 84 # |
85 # test everything | |
86 # | |
87 all : Makefile compile nocompile run norun complex | |
6 | 88 |
46 | 89 # |
72 | 90 # the tools |
91 # | |
92 return__ : return__.c | |
93 $(CC) $(CFLAGS) $< -o $@ | |
94 | |
95 ifeq__ : ifeq__.c | |
96 $(CC) $(CFLAGS) $< -o $@ | |
97 | |
98 basic_tools : Makefile $(ifeq__) $(return__) | |
99 | |
100 # | |
46 | 101 # include complex test cases |
102 # | |
103 complex_makefiles = $(sort $(shell $(FIND) complex -regex ".*$(complex_todo)")) | |
104 include $(complex_makefiles) | |
6 | 105 |
46 | 106 # |
107 # target should fail to compile | |
108 # | |
41
84e813a3e99b
fixed Makefile so that an edited makefile triggers a rebuild of outdated targets
thomask
parents:
32
diff
changeset
|
109 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 | 110 |
75 | 111 define analyse_nocompile |
72 | 112 @if $(ifeq__) $(z_return) 0 ; then \ |
46 | 113 $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
114 else \ | |
72 | 115 if $(ifeq__) $(z_return) 256 ; then \ |
116 $(ECHO) "XFAIL: $(z_name)"; $(TOUCH) $@; \ | |
117 else \ | |
75 | 118 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
72 | 119 fi \ |
46 | 120 fi |
75 | 121 endef |
122 | |
123 %.$(ext_nocompile) : %.$(ext_source) basic_tools | |
124 $(eval z_name = $(subst .$(ext_nocompile),,$@)) | |
125 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)")) | |
126 $(analyse_nocompile) | |
127 | |
128 %.$(ext_nocompile) : %.$(ext_source_html) basic_tools | |
129 $(eval z_name = $(subst .$(ext_nocompile),,$@)) | |
130 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)")) | |
131 $(analyse_nocompile) | |
32 | 132 |
46 | 133 # |
134 # target should compile (excludes linking) | |
135 # | |
41
84e813a3e99b
fixed Makefile so that an edited makefile triggers a rebuild of outdated targets
thomask
parents:
32
diff
changeset
|
136 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 | 137 |
75 | 138 define analyse_compile |
72 | 139 @if $(ifeq__) $(z_return) 0 ; then \ |
140 $(ECHO) "PASS: $(z_name)"; \ | |
46 | 141 else \ |
72 | 142 if $(ifeq__) $(z_return) 256 ; then \ |
143 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ | |
144 else \ | |
75 | 145 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; $(RM) $@; \ |
72 | 146 fi \ |
46 | 147 fi |
75 | 148 endef |
149 | |
150 %.$(ext_compile) : %.$(ext_source) basic_tools | |
151 $(eval z_name = $(subst .$(ext_compile),,$@)) | |
152 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)")) | |
153 $(analyse_compile) | |
154 | |
0 | 155 |
72 | 156 %.$(ext_compile) : %.$(ext_source_html) basic_tools |
46 | 157 $(eval z_name = $(subst .$(ext_compile),,$@)) |
72 | 158 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -c -of$@ $< $(to_log)")) |
75 | 159 $(analyse_compile) |
6 | 160 |
46 | 161 # |
162 # target should compile, link and run | |
163 # | |
41
84e813a3e99b
fixed Makefile so that an edited makefile triggers a rebuild of outdated targets
thomask
parents:
32
diff
changeset
|
164 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 | 165 |
75 | 166 define analyse_run |
72 | 167 @if $(ifeq__) $(z_return) 0 ; then \ |
168 if ./$@ $(to_log); then \ | |
46 | 169 $(ECHO) "PASS: $(z_name)"; \ |
170 else \ | |
72 | 171 $(ECHO) "FAIL: $(z_name)"; $(RM) $@; \ |
46 | 172 fi \ |
173 else \ | |
72 | 174 if $(ifeq__) $(z_return) 256 ; then \ |
175 $(ECHO) "FAIL: $(z_name) (compiling error)"; \ | |
176 else \ | |
75 | 177 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; \ |
72 | 178 fi \ |
46 | 179 fi |
75 | 180 endef |
46 | 181 |
75 | 182 %.$(ext_run) : %.$(ext_source) basic_tools |
72 | 183 $(eval z_name = $(subst .$(ext_run),,$@)) |
75 | 184 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)")) |
185 $(analyse_run) | |
0 | 186 |
72 | 187 %.$(ext_run) : %.$(ext_source_html) basic_tools |
63 | 188 $(eval z_name = $(subst .$(ext_run),,$@)) |
72 | 189 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)")) |
75 | 190 $(analyse_run) |
6 | 191 |
46 | 192 # |
193 # target should compile and link but fail to run | |
194 # | |
41
84e813a3e99b
fixed Makefile so that an edited makefile triggers a rebuild of outdated targets
thomask
parents:
32
diff
changeset
|
195 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 | 196 |
75 | 197 define analyse_norun |
72 | 198 @if $(ifeq__) $(z_return) 0; then \ |
199 if ./$@ $(to_log); \ | |
58 | 200 then $(ECHO) "XPASS: $(z_name)"; $(RM) $@; \ |
46 | 201 else \ |
72 | 202 $(ECHO) "XFAIL: $(z_name)"; \ |
46 | 203 fi \ |
204 else \ | |
72 | 205 if $(ifeq__) $(z_return) 256 ; then \ |
206 $(ECHO) "FAIL: $(z_name) (compiling error)"; $(RM) $@; \ | |
207 else \ | |
75 | 208 $(ECHO) "ERROR: $(z_name) [$(z_return)]"; \ |
72 | 209 fi \ |
46 | 210 fi |
75 | 211 endef |
212 | |
213 %.$(ext_norun) : %.$(ext_source) basic_tools | |
214 $(eval z_name = $(subst .$(ext_norun),,$@)) | |
215 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)")) | |
216 $(analyse_norun) | |
0 | 217 |
72 | 218 %.$(ext_norun) : %.$(ext_source_html) Makefile |
46 | 219 $(eval z_name = $(subst .$(ext_norun),,$@)) |
72 | 220 $(eval z_return = $(shell $(return__) "$(DMD) $(DFLAGS) -od$(OBJ_DIR) -of$@ $< $(to_log)")) |
75 | 221 $(analyse_norun) |
222 | |
46 | 223 |
224 # | |
225 # run all complex test cases | |
226 # | |
227 complex : $(sort $(subst $(complex_todo),$(complex_done),$(complex_makefiles))) | |
6 | 228 |
32 | 229 |
17 | 230 log : distclean all |
32 | 231 |
46 | 232 # |
233 # | |
234 # | |
17 | 235 distclean : clean_log clean |
72 | 236 $(RM) $(shell $(FIND) . -regex ".*~") |
6 | 237 |
46 | 238 # |
239 # remove compiler and assertion messages | |
240 # | |
0 | 241 clean_log : |
242 $(RM) $(LOG) | |
243 | |
72 | 244 #test.xx : |
245 # $(eval tempus=$(shell ./dstress_return "$(DMD) test.d -oftest.xx $(to_log)")) | |
246 # echo "$(tempus)" | |
247 | |
46 | 248 # |
249 # remove targets and all temp objects | |
250 # | |
251 clean : $(sort $(subst $(complex_todo),clean,$(complex_makefiles))) | |
252 $(RM) $(OBJ_DIR)/?*.?* | |
253 $(RM) run/?*.$(ext_run) norun/?*.$(ext_norun) compile/?*.$(ext_compile) nocompile/?*.$(ext_nocompile) |