Commit | Line | Data |
---|---|---|
5b207de7 JM |
1 | # Usage/help |
2 | all help: | |
3 | @echo | |
4 | @echo 'USAGE:' | |
5 | @echo | |
6 | @echo 'Rules/Targets:' | |
7 | @echo | |
8 | @echo 'make "IMPL" # build all steps of IMPL' | |
9 | @echo 'make "IMPL^STEP" # build STEP of IMPL' | |
10 | @echo | |
11 | @echo 'make "test" # test all implementations' | |
12 | @echo 'make "test^IMPL" # test all steps of IMPL' | |
13 | @echo 'make "test^STEP" # test STEP for all implementations' | |
14 | @echo 'make "test^IMPL^STEP" # test STEP of IMPL' | |
15 | @echo | |
16 | @echo 'make "perf" # run microbenchmarks for all implementations' | |
17 | @echo 'make "perf^IMPL" # run microbenchmarks for IMPL' | |
18 | @echo | |
19 | @echo 'make "repl^IMPL" # run stepA of IMPL' | |
20 | @echo 'make "repl^IMPL^STEP" # test STEP of IMPL' | |
21 | @echo | |
22 | @echo 'make "clean" # run 'make clean' for all implementations' | |
23 | @echo 'make "clean^IMPL" # run 'make clean' for IMPL' | |
24 | @echo | |
25 | @echo 'make "stats" # run 'make stats' for all implementations' | |
26 | @echo 'make "stats-lisp" # run 'make stats-lisp' for all implementations' | |
27 | @echo 'make "stats^IMPL" # run 'make stats' for IMPL' | |
28 | @echo 'make "stats-lisp^IMPL" # run 'make stats-lisp' for IMPL' | |
29 | @echo | |
30 | @echo 'Options/Settings:' | |
31 | @echo | |
32 | @echo 'make MAL_IMPL=IMPL "test^mal..." # use IMPL for self-host tests' | |
33 | @echo 'make REGRESS=1 "test..." # test with previous step tests too' | |
34 | @echo 'make DOCKERIZE=1 ... # to dockerize above rules/targets' | |
35 | @echo | |
36 | @echo 'Other:' | |
37 | @echo | |
38 | @echo 'make "docker-build^IMPL" # build docker image for IMPL' | |
39 | @echo | |
40 | ||
31690700 JM |
41 | # |
42 | # Command line settings | |
43 | # | |
44 | ||
45 | MAL_IMPL = js | |
46 | ||
a05f7822 | 47 | PYTHON = python |
47699629 | 48 | USE_MATLAB = |
32d0a1cf JM |
49 | # python, js, cpp, or neko are currently supported |
50 | HAXE_MODE = neko | |
a05f7822 | 51 | |
337c8031 JM |
52 | # Extra options to pass to runtest.py |
53 | TEST_OPTS = | |
54 | ||
17180e85 JM |
55 | # Test with previous test files not just the test files for the |
56 | # current step. Step 0 and 1 tests are special and not included in | |
57 | # later steps. | |
5b207de7 | 58 | REGRESS = |
17180e85 | 59 | |
337c8031 JM |
60 | # Extra implementation specific options to pass to runtest.py |
61 | mal_TEST_OPTS = --start-timeout 60 --test-timeout 120 | |
62 | ||
5b207de7 JM |
63 | # Run target/rule within docker image for the implementation |
64 | DOCKERIZE = | |
65 | ||
31690700 JM |
66 | # |
67 | # Settings | |
68 | # | |
69 | ||
0067158f JM |
70 | IMPLS = awk bash c d clojure coffee cpp crystal cs erlang elisp \ |
71 | elixir es6 factor forth fsharp go groovy guile haskell haxe \ | |
72 | io java julia js kotlin lua make mal ocaml matlab miniMAL \ | |
73 | nim objc objpascal perl php ps python r racket rpython ruby \ | |
74 | rust scala swift swift3 tcl vb vimscript | |
31690700 JM |
75 | |
76 | step0 = step0_repl | |
77 | step1 = step1_read_print | |
78 | step2 = step2_eval | |
79 | step3 = step3_env | |
80 | step4 = step4_if_fn_do | |
81 | step5 = step5_tco | |
82 | step6 = step6_file | |
83 | step7 = step7_quote | |
84 | step8 = step8_macros | |
01c97316 | 85 | step9 = step9_try |
90f618cb | 86 | stepA = stepA_mal |
31690700 | 87 | |
17180e85 JM |
88 | regress_step0 = step0 |
89 | regress_step1 = step1 | |
90 | regress_step2 = step2 | |
91 | regress_step3 = $(regress_step2) step3 | |
92 | regress_step4 = $(regress_step3) step4 | |
93 | regress_step5 = $(regress_step4) step5 | |
94 | regress_step6 = $(regress_step5) step6 | |
95 | regress_step7 = $(regress_step6) step7 | |
96 | regress_step8 = $(regress_step7) step8 | |
97 | regress_step9 = $(regress_step8) step9 | |
98 | regress_stepA = $(regress_step9) stepA | |
99 | ||
100 | STEP5_EXCLUDES += awk # completes at 10,000 | |
101 | STEP5_EXCLUDES += bash # no stack exhaustion or completion | |
102 | STEP5_EXCLUDES += c # segfault | |
103 | STEP5_EXCLUDES += cpp # completes at 10,000 | |
bcfd8b70 | 104 | STEP5_EXCLUDES += crystal # test completes, even at 1,000,000 |
17180e85 JM |
105 | STEP5_EXCLUDES += cs # fatal stack overflow fault |
106 | STEP5_EXCLUDES += d # completes at 10,000, fatal stack overflow at 1,000,000 | |
107 | STEP5_EXCLUDES += erlang # erlang is TCO, test passes | |
108 | STEP5_EXCLUDES += elixir # elixir is TCO, test passes | |
109 | STEP5_EXCLUDES += fsharp # completes at 10,000, fatal stack overflow at 100,000 | |
bcfd8b70 | 110 | STEP5_EXCLUDES += go # test completes, even at 100,000 |
17180e85 | 111 | STEP5_EXCLUDES += haskell # test completes |
3da6f492 | 112 | STEP5_EXCLUDES += io # too slow to complete 10,000 |
17180e85 JM |
113 | STEP5_EXCLUDES += make # no TCO capability/step |
114 | STEP5_EXCLUDES += mal # no TCO capability/step | |
47699629 | 115 | STEP5_EXCLUDES += matlab # too slow to complete 10,000 |
17180e85 JM |
116 | STEP5_EXCLUDES += miniMAL # strange error with runtest.py |
117 | STEP5_EXCLUDES += nim # test completes, even at 100,000 | |
2faae94c | 118 | STEP5_EXCLUDES += objc # completes at 10,000, crashes at 100,000 |
0067158f | 119 | STEP5_EXCLUDES += objpascal # completes at 10,000 |
17180e85 JM |
120 | STEP5_EXCLUDES += php # test completes, even at 100,000 |
121 | STEP5_EXCLUDES += racket # test completes | |
122 | STEP5_EXCLUDES += ruby # test completes, even at 100,000 | |
123 | STEP5_EXCLUDES += rust # no catching stack overflows | |
0067158f | 124 | STEP5_EXCLUDES += swift3 # no catching stack overflows |
17180e85 JM |
125 | STEP5_EXCLUDES += ocaml # test completes, even at 1,000,000 |
126 | STEP5_EXCLUDES += vb # completes at 10,000 | |
17180e85 JM |
127 | |
128 | PERF_EXCLUDES = mal # TODO: fix this | |
31690700 | 129 | |
bcfd8b70 | 130 | dist_EXCLUDES += mal |
5245b079 | 131 | # TODO: still need to implement dist |
bcfd8b70 | 132 | dist_EXCLUDES += guile io julia matlab swift |
5245b079 | 133 | |
31690700 JM |
134 | # |
135 | # Utility functions | |
136 | # | |
137 | ||
47699629 JM |
138 | MATLAB = matlab -nodisplay -nosplash -nodesktop -nojvm -r |
139 | OCTAVE = octave --no-gui -q --traditional --eval | |
140 | matlab_args = $(subst $(SPACE),$(COMMA),$(foreach x,$(strip $(1)),'$(x)')) | |
141 | matlab_cmd = $(if $(strip $(USE_MATLAB)),$(MATLAB),$(OCTAVE)) | |
142 | ||
32d0a1cf JM |
143 | haxe_STEP_TO_PROG_neko = haxe/$($(1)).n |
144 | haxe_STEP_TO_PROG_python = haxe/$($(1)).py | |
145 | haxe_STEP_TO_PROG_cpp = haxe/cpp/$($(1)) | |
146 | haxe_STEP_TO_PROG_js = haxe/$($(1)).js | |
147 | ||
148 | haxe_RUNSTEP_neko = neko ../$(2) $(3) | |
149 | haxe_RUNSTEP_python = python3 ../$(2) $(3) | |
150 | haxe_RUNSTEP_cpp = ../$(2) $(3) | |
151 | haxe_RUNSTEP_js = node ../$(2) $(3) | |
152 | ||
17180e85 JM |
153 | # Return list of test files for a given step. If REGRESS is set then |
154 | # test files will include step 2 tests through tests for the step | |
155 | # being tested. | |
156 | STEP_TEST_FILES = $(strip $(wildcard \ | |
157 | $(foreach s,$(if $(strip $(REGRESS)),$(regress_$(2)),$(2)),\ | |
158 | $(1)/tests/$($(s)).mal tests/$($(s)).mal))) | |
31690700 | 159 | |
17180e85 | 160 | # Map of step (e.g. "step8") to executable file for that step |
3b7ef8c7 | 161 | awk_STEP_TO_PROG = awk/$($(1)).awk |
db4c329a JM |
162 | bash_STEP_TO_PROG = bash/$($(1)).sh |
163 | c_STEP_TO_PROG = c/$($(1)) | |
f82cb965 | 164 | d_STEP_TO_PROG = d/$($(1)) |
31690700 | 165 | clojure_STEP_TO_PROG = clojure/src/$($(1)).clj |
891c3f3b | 166 | coffee_STEP_TO_PROG = coffee/$($(1)).coffee |
9ddaa0b9 | 167 | cpp_STEP_TO_PROG = cpp/$($(1)) |
86fe6314 | 168 | crystal_STEP_TO_PROG = crystal/$($(1)) |
db4c329a | 169 | cs_STEP_TO_PROG = cs/$($(1)).exe |
ae28e856 | 170 | elisp_STEP_TO_PROG = elisp/$($(1)).el |
51c2c1fe | 171 | elixir_STEP_TO_PROG = elixir/lib/mix/tasks/$($(1)).ex |
2cc3804b | 172 | erlang_STEP_TO_PROG = erlang/$($(1)) |
4eb71990 | 173 | es6_STEP_TO_PROG = es6/build/$($(1)).js |
199b1ce7 | 174 | factor_STEP_TO_PROG = factor/$($(1))/$($(1)).factor |
59038a10 | 175 | forth_STEP_TO_PROG = forth/$($(1)).fs |
1c358979 | 176 | fsharp_STEP_TO_PROG = fsharp/$($(1)).exe |
69b4abd6 | 177 | go_STEP_TO_PROG = go/$($(1)) |
a9cd6543 | 178 | groovy_STEP_TO_PROG = groovy/$($(1)).groovy |
36e287b5 | 179 | java_STEP_TO_PROG = java/target/classes/mal/$($(1)).class |
b76aa73b | 180 | haskell_STEP_TO_PROG = haskell/$($(1)) |
32d0a1cf | 181 | haxe_STEP_TO_PROG = $(haxe_STEP_TO_PROG_$(HAXE_MODE)) |
7511317b | 182 | io_STEP_TO_PROG = io/$($(1)).io |
a23e0cdb | 183 | julia_STEP_TO_PROG = julia/$($(1)).jl |
db4c329a | 184 | js_STEP_TO_PROG = js/$($(1)).js |
53c2ea70 | 185 | kotlin_STEP_TO_PROG = kotlin/$($(1)).jar |
9d42904e | 186 | lua_STEP_TO_PROG = lua/$($(1)).lua |
db4c329a JM |
187 | make_STEP_TO_PROG = make/$($(1)).mk |
188 | mal_STEP_TO_PROG = mal/$($(1)).mal | |
59d10e1b | 189 | ocaml_STEP_TO_PROG = ocaml/$($(1)) |
9a54ea18 | 190 | matlab_STEP_TO_PROG = matlab/$($(1)).m |
c1fe72ae | 191 | miniMAL_STEP_TO_PROG = miniMAL/$($(1)).json |
dbac60df | 192 | nim_STEP_TO_PROG = nim/$($(1)) |
2faae94c | 193 | objc_STEP_TO_PROG = objc/$($(1)) |
0067158f | 194 | objpascal_STEP_TO_PROG = objpascal/$($(1)) |
b5dedee0 | 195 | perl_STEP_TO_PROG = perl/$($(1)).pl |
db4c329a JM |
196 | php_STEP_TO_PROG = php/$($(1)).php |
197 | ps_STEP_TO_PROG = ps/$($(1)).ps | |
198 | python_STEP_TO_PROG = python/$($(1)).py | |
4d1456b9 | 199 | r_STEP_TO_PROG = r/$($(1)).r |
f5223195 | 200 | racket_STEP_TO_PROG = racket/$($(1)).rkt |
80320efc | 201 | rpython_STEP_TO_PROG = rpython/$($(1)) |
db4c329a | 202 | ruby_STEP_TO_PROG = ruby/$($(1)).rb |
434516e0 | 203 | rust_STEP_TO_PROG = rust/target/release/$($(1)) |
821930db | 204 | scala_STEP_TO_PROG = scala/$($(1)).scala |
2539e6af | 205 | swift_STEP_TO_PROG = swift/$($(1)) |
0eace3df | 206 | swift3_STEP_TO_PROG = swift3/$($(1)) |
54d9903c | 207 | tcl_STEP_TO_PROG = tcl/$($(1)).tcl |
ee7cd585 | 208 | vb_STEP_TO_PROG = vb/$($(1)).exe |
50a964ce | 209 | vimscript_STEP_TO_PROG = vimscript/$($(1)).vim |
5eb1f5cb | 210 | guile_STEP_TO_PROG = guile/$($(1)).scm |
db4c329a | 211 | |
17180e85 | 212 | |
c4033aab JM |
213 | # Needed some argument munging |
214 | COMMA = , | |
215 | noop = | |
216 | SPACE = $(noop) $(noop) | |
d1596ac2 | 217 | export FACTOR_ROOTS := . |
db4c329a | 218 | |
17180e85 JM |
219 | # Macro for running a step: |
220 | # $(1): step (e.g. "stepA") | |
221 | # $(2): program for step (e.g. result of *_STEP_TO_PROG | |
222 | # $(3): program arguments | |
3b7ef8c7 | 223 | awk_RUNSTEP = awk -O -f ../$(2) $(3) |
db4c329a JM |
224 | bash_RUNSTEP = bash ../$(2) $(3) |
225 | c_RUNSTEP = ../$(2) $(3) | |
f82cb965 | 226 | d_RUNSTEP = ../$(2) $(3) |
db4c329a | 227 | clojure_RUNSTEP = lein with-profile +$(1) trampoline run $(3) |
891c3f3b | 228 | coffee_RUNSTEP = coffee ../$(2) $(3) |
9ddaa0b9 | 229 | cpp_RUNSTEP = ../$(2) $(3) |
86fe6314 | 230 | crystal_RUNSTEP = ../$(2) $(3) |
db4c329a | 231 | cs_RUNSTEP = mono ../$(2) --raw $(3) |
ae28e856 | 232 | elisp_RUNSTEP = emacs -Q --batch --load ../$(2) $(3) |
df2ca97b | 233 | elixir_RUNSTEP = mix $(notdir $(basename $(2))) $(3) |
2cc3804b | 234 | erlang_RUNSTEP = ../$(2) $(3) |
4eb71990 | 235 | es6_RUNSTEP = node ../$(2) $(3) |
389c9b8a | 236 | factor_RUNSTEP = factor ../$(2) $(3) |
59038a10 | 237 | forth_RUNSTEP = gforth ../$(2) $(3) |
1c358979 | 238 | fsharp_RUNSTEP = mono ../$(2) --raw $(3) |
69b4abd6 | 239 | go_RUNSTEP = ../$(2) $(3) |
a9cd6543 | 240 | groovy_RUNSTEP = groovy ../$(2) $(3) |
5245b079 JM |
241 | # needs TERM=dumb to work with readline |
242 | guile_RUNSTEP = guile --no-auto-compile -L ../guile ../$(2) $(3) | |
b76aa73b | 243 | haskell_RUNSTEP = ../$(2) $(3) |
6c4c14bd | 244 | haxe_RUNSTEP = python3 ../$(2) $(3) |
32d0a1cf | 245 | haxe_RUNSTEP = $(haxe_RUNSTEP_$(HAXE_MODE)) |
7511317b | 246 | io_RUNSTEP = io ../$(2) $(3) |
798206ac | 247 | java_RUNSTEP = mvn -quiet exec:java -Dexec.mainClass="mal.$($(1))" $(if $(3), -Dexec.args="$(3)",) |
a23e0cdb | 248 | julia_RUNSTEP = ../$(2) $(3) |
db4c329a | 249 | js_RUNSTEP = node ../$(2) $(3) |
53c2ea70 | 250 | kotlin_RUNSTEP = java -jar ../$(2) $(3) |
798206ac | 251 | lua_RUNSTEP = ../$(2) $(3) |
db4c329a | 252 | make_RUNSTEP = make -f ../$(2) $(3) |
922d4c3b | 253 | mal_RUNSTEP = $(call $(MAL_IMPL)_RUNSTEP,stepA,$(call $(MAL_IMPL)_STEP_TO_PROG,stepA),../$(2),") #" |
59d10e1b | 254 | ocaml_RUNSTEP = ../$(2) $(3) |
47699629 | 255 | matlab_RUNSTEP = $(matlab_cmd) "$($(1))($(call matlab_args,$(3)));quit;" |
c1fe72ae | 256 | miniMAL_RUNSTEP = miniMAL ../$(2) $(3) |
dbac60df | 257 | nim_RUNSTEP = ../$(2) $(3) |
2faae94c | 258 | objc_RUNSTEP = ../$(2) $(3) |
0067158f | 259 | objpascal_RUNSTEP = ../$(2) $(3) |
82acd3de | 260 | perl_RUNSTEP = perl ../$(2) $(3) |
db4c329a | 261 | php_RUNSTEP = php ../$(2) $(3) |
406761e7 | 262 | ps_RUNSTEP = gs -q -I./ -dNODISPLAY -- ../$(2) $(3) |
db4c329a | 263 | python_RUNSTEP = $(PYTHON) ../$(2) $(3) |
4d1456b9 | 264 | r_RUNSTEP = Rscript ../$(2) $(3) |
f5223195 | 265 | racket_RUNSTEP = ../$(2) $(3) |
80320efc | 266 | rpython_RUNSTEP = ../$(2) $(3) |
db4c329a | 267 | ruby_RUNSTEP = ruby ../$(2) $(3) |
abdd56eb | 268 | rust_RUNSTEP = ../$(2) $(3) |
821930db | 269 | scala_RUNSTEP = sbt 'run-main $($(1))$(if $(3), $(3),)' |
2539e6af | 270 | swift_RUNSTEP = ../$(2) $(3) |
0eace3df | 271 | swift3_RUNSTEP = ../$(2) $(3) |
576ef370 | 272 | tcl_RUNSTEP = tclsh ../$(2) --raw $(3) |
ee7cd585 | 273 | vb_RUNSTEP = mono ../$(2) --raw $(3) |
50a964ce | 274 | vimscript_RUNSTEP = ./run_vimscript.sh ../$(2) $(3) |
db4c329a | 275 | |
31690700 | 276 | |
4959b19d JM |
277 | # DOCKERIZE utility functions |
278 | lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) | |
279 | impl_to_image = kanaka/mal-test-$(call lc,$(1)) | |
280 | ||
281 | actual_impl = $(if $(filter mal,$(1)),$(MAL_IMPL),$(1)) | |
282 | ||
283 | get_build_prefix = $(if $(strip $(DOCKERIZE)),docker run -it --rm -u $(shell id -u) -v $(dir $(abspath $(lastword $(MAKEFILE_LIST)))):/mal -w /mal/$(1) $(if $(filter factor,$(1)),-e FACTOR_ROOTS=$(FACTOR_ROOTS),) $(call impl_to_image,$(1)) ,) | |
284 | get_run_prefix = $(if $(strip $(DOCKERIZE)),docker run -it --rm -u $(shell id -u) -v $(dir $(abspath $(lastword $(MAKEFILE_LIST)))):/mal -w /mal/$(call actual_impl,$(1)) $(if $(filter factor,$(1)),-e FACTOR_ROOTS=$(FACTOR_ROOTS),) $(call impl_to_image,$(call actual_impl,$(1))) ,) | |
285 | ||
286 | ||
50a964ce DM |
287 | vimscript_TEST_OPTS = --test-timeout 30 |
288 | ifeq ($(MAL_IMPL),vimscript) | |
289 | mal_TEST_OPTS = --start-timeout 60 --test-timeout 180 | |
290 | endif | |
31690700 JM |
291 | |
292 | # Derived lists | |
293 | STEPS = $(sort $(filter step%,$(.VARIABLES))) | |
8569b2af JM |
294 | DO_IMPLS = $(filter-out $(SKIP_IMPLS),$(IMPLS)) |
295 | IMPL_TESTS = $(foreach impl,$(DO_IMPLS),test^$(impl)) | |
31690700 | 296 | STEP_TESTS = $(foreach step,$(STEPS),test^$(step)) |
17180e85 | 297 | ALL_TESTS = $(filter-out $(foreach impl,$(STEP5_EXCLUDES),test^$(impl)^step5),\ |
31690700 | 298 | $(strip $(sort \ |
8569b2af | 299 | $(foreach impl,$(DO_IMPLS),\ |
31690700 JM |
300 | $(foreach step,$(STEPS),test^$(impl)^$(step)))))) |
301 | ||
cf1d3eae JM |
302 | DOCKER_BUILD = $(foreach impl,$(DO_IMPLS),docker-build^$(impl)) |
303 | ||
17180e85 | 304 | IMPL_PERF = $(foreach impl,$(filter-out $(PERF_EXCLUDES),$(DO_IMPLS)),perf^$(impl)) |
db4c329a | 305 | |
854cf2a6 DM |
306 | IMPL_REPL = $(foreach impl,$(DO_IMPLS),repl^$(impl)) |
307 | ALL_REPL = $(strip $(sort \ | |
308 | $(foreach impl,$(DO_IMPLS),\ | |
309 | $(foreach step,$(STEPS),repl^$(impl)^$(step))))) | |
310 | ||
31690700 JM |
311 | # |
312 | # Build rules | |
313 | # | |
314 | ||
4fc7a281 | 315 | # Build a program in an implementation directory |
f045aba1 JM |
316 | # Make sure we always try and build first because the dependencies are |
317 | # encoded in the implementation Makefile not here | |
318 | .PHONY: $(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),$(call $(i)_STEP_TO_PROG,$(s)))) | |
4fc7a281 | 319 | $(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),$(call $(i)_STEP_TO_PROG,$(s)))): |
f045aba1 | 320 | $(foreach impl,$(word 1,$(subst /, ,$(@))),\ |
4959b19d JM |
321 | $(if $(DOCKERIZE), \ |
322 | $(call get_build_prefix,$(impl))$(MAKE) $(patsubst $(impl)/%,%,$(@)), \ | |
323 | $(MAKE) -C $(impl) $(subst $(impl)/,,$(@)))) | |
9ddaa0b9 | 324 | |
5b207de7 | 325 | # Allow IMPL, and IMPL^STEP |
31690700 | 326 | .SECONDEXPANSION: |
5b207de7 | 327 | $(DO_IMPLS): $$(foreach s,$$(STEPS),$$(call $$(@)_STEP_TO_PROG,$$(s))) |
31690700 JM |
328 | |
329 | .SECONDEXPANSION: | |
5b207de7 JM |
330 | $(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),$(i)^$(s))): $$(call $$(word 1,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 2,$$(subst ^, ,$$(@)))) |
331 | ||
332 | ||
333 | # | |
334 | # Test rules | |
335 | # | |
31690700 JM |
336 | |
337 | .SECONDEXPANSION: | |
338 | $(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@)))) | |
339 | @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\ | |
340 | $(foreach step,$(word 3,$(subst ^, ,$(@))),\ | |
341 | cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \ | |
342 | $(foreach test,$(call STEP_TEST_FILES,$(impl),$(step)),\ | |
343 | echo '----------------------------------------------'; \ | |
344 | echo 'Testing $@, step file: $+, test file: $(test)'; \ | |
4959b19d JM |
345 | echo 'Running: $(call get_run_prefix,$(impl))../runtest.py $(TEST_OPTS) $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+))'; \ |
346 | $(call get_run_prefix,$(impl))../runtest.py $(TEST_OPTS) $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+));))) | |
31690700 | 347 | |
5b207de7 | 348 | # Allow test, tests, test^STEP, test^IMPL, and test^IMPL^STEP |
4959b19d JM |
349 | test: $(ALL_TESTS) |
350 | tests: $(ALL_TESTS) | |
712af9ef | 351 | |
5b207de7 JM |
352 | .SECONDEXPANSION: |
353 | $(IMPL_TESTS): $$(filter $$@^%,$$(ALL_TESTS)) | |
354 | ||
355 | .SECONDEXPANSION: | |
356 | $(STEP_TESTS): $$(foreach step,$$(subst test^,,$$@),$$(filter %^$$(step),$$(ALL_TESTS))) | |
357 | ||
358 | ||
359 | # | |
360 | # Dist rules | |
361 | # | |
b6dc3e37 JM |
362 | |
363 | dist: $(IMPL_DIST) | |
364 | ||
365 | .SECONDEXPANSION: | |
366 | $(IMPL_DIST): | |
367 | @echo "----------------------------------------------"; \ | |
368 | $(foreach impl,$(word 2,$(subst ^, ,$(@))),\ | |
369 | echo "Running: make -C $(impl) dist"; \ | |
370 | $(MAKE) --no-print-directory -C $(impl) dist) | |
371 | ||
5b207de7 JM |
372 | |
373 | # | |
cf1d3eae | 374 | # Docker build rules |
5b207de7 | 375 | # |
cf1d3eae JM |
376 | |
377 | docker-build: $(DOCKER_BUILD) | |
378 | ||
379 | .SECONDEXPANSION: | |
380 | $(DOCKER_BUILD): | |
381 | echo "----------------------------------------------"; \ | |
382 | $(foreach impl,$(word 2,$(subst ^, ,$(@))),\ | |
4959b19d JM |
383 | echo "Running: docker build -t $(call impl_to_image,$(impl)) .:"; \ |
384 | cd $(impl) && docker build -t $(call impl_to_image,$(impl)) .) | |
db4c329a | 385 | |
5b207de7 JM |
386 | |
387 | # | |
db4c329a | 388 | # Performance test rules |
5b207de7 | 389 | # |
db4c329a JM |
390 | |
391 | perf: $(IMPL_PERF) | |
392 | ||
393 | .SECONDEXPANSION: | |
394 | $(IMPL_PERF): | |
395 | @echo "----------------------------------------------"; \ | |
396 | $(foreach impl,$(word 2,$(subst ^, ,$(@))),\ | |
397 | cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \ | |
398 | echo "Performance test for $(impl):"; \ | |
4959b19d JM |
399 | echo 'Running: $(call get_run_prefix,$(impl))$(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal)'; \ |
400 | $(call get_run_prefix,$(impl))$(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal); \ | |
db4c329a | 401 | echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal)'; \ |
4959b19d | 402 | $(call get_run_prefix,$(impl))$(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal); \ |
699f0ad2 | 403 | echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf3.mal)'; \ |
4959b19d JM |
404 | $(call get_run_prefix,$(impl))$(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf3.mal)) |
405 | ||
854cf2a6 | 406 | |
5b207de7 | 407 | # |
854cf2a6 | 408 | # REPL invocation rules |
5b207de7 | 409 | # |
854cf2a6 DM |
410 | |
411 | .SECONDEXPANSION: | |
412 | $(ALL_REPL): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@)))) | |
413 | @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\ | |
414 | $(foreach step,$(word 3,$(subst ^, ,$(@))),\ | |
415 | cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \ | |
416 | echo 'REPL implementation $(impl), step file: $+'; \ | |
4959b19d JM |
417 | echo 'Running: $(call get_run_prefix,$(impl))$(call $(impl)_RUNSTEP,$(step),$(+))'; \ |
418 | $(call get_run_prefix,$(impl))$(call $(impl)_RUNSTEP,$(step),$(+));)) | |
bcfd8b70 | 419 | |
5b207de7 JM |
420 | # Allow repl^IMPL^STEP and repl^IMPL (which starts REPL of stepA) |
421 | .SECONDEXPANSION: | |
422 | $(IMPL_REPL): $$@^stepA | |
423 | ||
bcfd8b70 | 424 | |
5b207de7 | 425 | # |
bcfd8b70 | 426 | # Recursive rules (call make FOO in each subdirectory) |
5b207de7 | 427 | # |
bcfd8b70 JM |
428 | |
429 | define recur_template | |
430 | .PHONY: $(1) | |
431 | $(1): $(2) | |
432 | .SECONDEXPANSION: | |
433 | $(2): | |
434 | @echo "----------------------------------------------"; \ | |
435 | $$(foreach impl,$$(word 2,$$(subst ^, ,$$(@))),\ | |
4959b19d JM |
436 | $$(if $$(DOCKERIZE), \ |
437 | echo "Running: $$(call get_build_prefix,$$(impl))$$(MAKE) --no-print-directory $(1)"; \ | |
438 | $$(call get_build_prefix,$$(impl))$$(MAKE) --no-print-directory $(1), \ | |
439 | echo "Running: $$(MAKE) --no-print-directory -C $$(impl) $(1)"; \ | |
440 | $$(MAKE) --no-print-directory -C $$(impl) $(1))) | |
bcfd8b70 JM |
441 | endef |
442 | ||
443 | recur_impls_ = $(filter-out $(foreach impl,$($(1)_EXCLUDES),$(1)^$(impl)),$(foreach impl,$(IMPLS),$(1)^$(impl))) | |
444 | ||
445 | # recursive clean | |
446 | $(eval $(call recur_template,clean,$(call recur_impls_,clean))) | |
447 | ||
448 | # recursive stats | |
449 | $(eval $(call recur_template,stats,$(call recur_impls_,stats))) | |
450 | $(eval $(call recur_template,stats-lisp,$(call recur_impls_,stats-lisp))) | |
451 | ||
452 | # recursive dist | |
453 | $(eval $(call recur_template,dist,$(call recur_impls_,dist))) |