Update README test count. Update docs/TODO.
[jackhill/mal.git] / Makefile
CommitLineData
5b207de7
JM
1# Usage/help
2all 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
45MAL_IMPL = js
46
a05f7822 47PYTHON = python
47699629 48USE_MATLAB =
32d0a1cf
JM
49# python, js, cpp, or neko are currently supported
50HAXE_MODE = neko
a05f7822 51
337c8031
JM
52# Extra options to pass to runtest.py
53TEST_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 58REGRESS =
17180e85 59
337c8031
JM
60# Extra implementation specific options to pass to runtest.py
61mal_TEST_OPTS = --start-timeout 60 --test-timeout 120
62
5b207de7
JM
63# Run target/rule within docker image for the implementation
64DOCKERIZE =
65
31690700
JM
66#
67# Settings
68#
69
0067158f
JM
70IMPLS = 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
76step0 = step0_repl
77step1 = step1_read_print
78step2 = step2_eval
79step3 = step3_env
80step4 = step4_if_fn_do
81step5 = step5_tco
82step6 = step6_file
83step7 = step7_quote
84step8 = step8_macros
01c97316 85step9 = step9_try
90f618cb 86stepA = stepA_mal
31690700 87
17180e85
JM
88regress_step0 = step0
89regress_step1 = step1
90regress_step2 = step2
91regress_step3 = $(regress_step2) step3
92regress_step4 = $(regress_step3) step4
93regress_step5 = $(regress_step4) step5
94regress_step6 = $(regress_step5) step6
95regress_step7 = $(regress_step6) step7
96regress_step8 = $(regress_step7) step8
97regress_step9 = $(regress_step8) step9
98regress_stepA = $(regress_step9) stepA
99
100STEP5_EXCLUDES += awk # completes at 10,000
101STEP5_EXCLUDES += bash # no stack exhaustion or completion
102STEP5_EXCLUDES += c # segfault
103STEP5_EXCLUDES += cpp # completes at 10,000
bcfd8b70 104STEP5_EXCLUDES += crystal # test completes, even at 1,000,000
17180e85
JM
105STEP5_EXCLUDES += cs # fatal stack overflow fault
106STEP5_EXCLUDES += d # completes at 10,000, fatal stack overflow at 1,000,000
107STEP5_EXCLUDES += erlang # erlang is TCO, test passes
108STEP5_EXCLUDES += elixir # elixir is TCO, test passes
109STEP5_EXCLUDES += fsharp # completes at 10,000, fatal stack overflow at 100,000
bcfd8b70 110STEP5_EXCLUDES += go # test completes, even at 100,000
17180e85 111STEP5_EXCLUDES += haskell # test completes
3da6f492 112STEP5_EXCLUDES += io # too slow to complete 10,000
17180e85
JM
113STEP5_EXCLUDES += make # no TCO capability/step
114STEP5_EXCLUDES += mal # no TCO capability/step
47699629 115STEP5_EXCLUDES += matlab # too slow to complete 10,000
17180e85
JM
116STEP5_EXCLUDES += miniMAL # strange error with runtest.py
117STEP5_EXCLUDES += nim # test completes, even at 100,000
2faae94c 118STEP5_EXCLUDES += objc # completes at 10,000, crashes at 100,000
0067158f 119STEP5_EXCLUDES += objpascal # completes at 10,000
17180e85
JM
120STEP5_EXCLUDES += php # test completes, even at 100,000
121STEP5_EXCLUDES += racket # test completes
122STEP5_EXCLUDES += ruby # test completes, even at 100,000
123STEP5_EXCLUDES += rust # no catching stack overflows
0067158f 124STEP5_EXCLUDES += swift3 # no catching stack overflows
17180e85
JM
125STEP5_EXCLUDES += ocaml # test completes, even at 1,000,000
126STEP5_EXCLUDES += vb # completes at 10,000
17180e85
JM
127
128PERF_EXCLUDES = mal # TODO: fix this
31690700 129
bcfd8b70 130dist_EXCLUDES += mal
5245b079 131# TODO: still need to implement dist
bcfd8b70 132dist_EXCLUDES += guile io julia matlab swift
5245b079 133
31690700
JM
134#
135# Utility functions
136#
137
47699629
JM
138MATLAB = matlab -nodisplay -nosplash -nodesktop -nojvm -r
139OCTAVE = octave --no-gui -q --traditional --eval
140matlab_args = $(subst $(SPACE),$(COMMA),$(foreach x,$(strip $(1)),'$(x)'))
141matlab_cmd = $(if $(strip $(USE_MATLAB)),$(MATLAB),$(OCTAVE))
142
32d0a1cf
JM
143haxe_STEP_TO_PROG_neko = haxe/$($(1)).n
144haxe_STEP_TO_PROG_python = haxe/$($(1)).py
145haxe_STEP_TO_PROG_cpp = haxe/cpp/$($(1))
146haxe_STEP_TO_PROG_js = haxe/$($(1)).js
147
148haxe_RUNSTEP_neko = neko ../$(2) $(3)
149haxe_RUNSTEP_python = python3 ../$(2) $(3)
150haxe_RUNSTEP_cpp = ../$(2) $(3)
151haxe_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.
156STEP_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 161awk_STEP_TO_PROG = awk/$($(1)).awk
db4c329a
JM
162bash_STEP_TO_PROG = bash/$($(1)).sh
163c_STEP_TO_PROG = c/$($(1))
f82cb965 164d_STEP_TO_PROG = d/$($(1))
31690700 165clojure_STEP_TO_PROG = clojure/src/$($(1)).clj
891c3f3b 166coffee_STEP_TO_PROG = coffee/$($(1)).coffee
9ddaa0b9 167cpp_STEP_TO_PROG = cpp/$($(1))
86fe6314 168crystal_STEP_TO_PROG = crystal/$($(1))
db4c329a 169cs_STEP_TO_PROG = cs/$($(1)).exe
ae28e856 170elisp_STEP_TO_PROG = elisp/$($(1)).el
51c2c1fe 171elixir_STEP_TO_PROG = elixir/lib/mix/tasks/$($(1)).ex
2cc3804b 172erlang_STEP_TO_PROG = erlang/$($(1))
4eb71990 173es6_STEP_TO_PROG = es6/build/$($(1)).js
199b1ce7 174factor_STEP_TO_PROG = factor/$($(1))/$($(1)).factor
59038a10 175forth_STEP_TO_PROG = forth/$($(1)).fs
1c358979 176fsharp_STEP_TO_PROG = fsharp/$($(1)).exe
69b4abd6 177go_STEP_TO_PROG = go/$($(1))
a9cd6543 178groovy_STEP_TO_PROG = groovy/$($(1)).groovy
36e287b5 179java_STEP_TO_PROG = java/target/classes/mal/$($(1)).class
b76aa73b 180haskell_STEP_TO_PROG = haskell/$($(1))
32d0a1cf 181haxe_STEP_TO_PROG = $(haxe_STEP_TO_PROG_$(HAXE_MODE))
7511317b 182io_STEP_TO_PROG = io/$($(1)).io
a23e0cdb 183julia_STEP_TO_PROG = julia/$($(1)).jl
db4c329a 184js_STEP_TO_PROG = js/$($(1)).js
53c2ea70 185kotlin_STEP_TO_PROG = kotlin/$($(1)).jar
9d42904e 186lua_STEP_TO_PROG = lua/$($(1)).lua
db4c329a
JM
187make_STEP_TO_PROG = make/$($(1)).mk
188mal_STEP_TO_PROG = mal/$($(1)).mal
59d10e1b 189ocaml_STEP_TO_PROG = ocaml/$($(1))
9a54ea18 190matlab_STEP_TO_PROG = matlab/$($(1)).m
c1fe72ae 191miniMAL_STEP_TO_PROG = miniMAL/$($(1)).json
dbac60df 192nim_STEP_TO_PROG = nim/$($(1))
2faae94c 193objc_STEP_TO_PROG = objc/$($(1))
0067158f 194objpascal_STEP_TO_PROG = objpascal/$($(1))
b5dedee0 195perl_STEP_TO_PROG = perl/$($(1)).pl
db4c329a
JM
196php_STEP_TO_PROG = php/$($(1)).php
197ps_STEP_TO_PROG = ps/$($(1)).ps
198python_STEP_TO_PROG = python/$($(1)).py
4d1456b9 199r_STEP_TO_PROG = r/$($(1)).r
f5223195 200racket_STEP_TO_PROG = racket/$($(1)).rkt
80320efc 201rpython_STEP_TO_PROG = rpython/$($(1))
db4c329a 202ruby_STEP_TO_PROG = ruby/$($(1)).rb
434516e0 203rust_STEP_TO_PROG = rust/target/release/$($(1))
821930db 204scala_STEP_TO_PROG = scala/$($(1)).scala
2539e6af 205swift_STEP_TO_PROG = swift/$($(1))
0eace3df 206swift3_STEP_TO_PROG = swift3/$($(1))
54d9903c 207tcl_STEP_TO_PROG = tcl/$($(1)).tcl
ee7cd585 208vb_STEP_TO_PROG = vb/$($(1)).exe
50a964ce 209vimscript_STEP_TO_PROG = vimscript/$($(1)).vim
5eb1f5cb 210guile_STEP_TO_PROG = guile/$($(1)).scm
db4c329a 211
17180e85 212
c4033aab
JM
213# Needed some argument munging
214COMMA = ,
215noop =
216SPACE = $(noop) $(noop)
d1596ac2 217export 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 223awk_RUNSTEP = awk -O -f ../$(2) $(3)
db4c329a
JM
224bash_RUNSTEP = bash ../$(2) $(3)
225c_RUNSTEP = ../$(2) $(3)
f82cb965 226d_RUNSTEP = ../$(2) $(3)
db4c329a 227clojure_RUNSTEP = lein with-profile +$(1) trampoline run $(3)
891c3f3b 228coffee_RUNSTEP = coffee ../$(2) $(3)
9ddaa0b9 229cpp_RUNSTEP = ../$(2) $(3)
86fe6314 230crystal_RUNSTEP = ../$(2) $(3)
db4c329a 231cs_RUNSTEP = mono ../$(2) --raw $(3)
ae28e856 232elisp_RUNSTEP = emacs -Q --batch --load ../$(2) $(3)
df2ca97b 233elixir_RUNSTEP = mix $(notdir $(basename $(2))) $(3)
2cc3804b 234erlang_RUNSTEP = ../$(2) $(3)
4eb71990 235es6_RUNSTEP = node ../$(2) $(3)
389c9b8a 236factor_RUNSTEP = factor ../$(2) $(3)
59038a10 237forth_RUNSTEP = gforth ../$(2) $(3)
1c358979 238fsharp_RUNSTEP = mono ../$(2) --raw $(3)
69b4abd6 239go_RUNSTEP = ../$(2) $(3)
a9cd6543 240groovy_RUNSTEP = groovy ../$(2) $(3)
5245b079
JM
241# needs TERM=dumb to work with readline
242guile_RUNSTEP = guile --no-auto-compile -L ../guile ../$(2) $(3)
b76aa73b 243haskell_RUNSTEP = ../$(2) $(3)
6c4c14bd 244haxe_RUNSTEP = python3 ../$(2) $(3)
32d0a1cf 245haxe_RUNSTEP = $(haxe_RUNSTEP_$(HAXE_MODE))
7511317b 246io_RUNSTEP = io ../$(2) $(3)
798206ac 247java_RUNSTEP = mvn -quiet exec:java -Dexec.mainClass="mal.$($(1))" $(if $(3), -Dexec.args="$(3)",)
a23e0cdb 248julia_RUNSTEP = ../$(2) $(3)
db4c329a 249js_RUNSTEP = node ../$(2) $(3)
53c2ea70 250kotlin_RUNSTEP = java -jar ../$(2) $(3)
798206ac 251lua_RUNSTEP = ../$(2) $(3)
db4c329a 252make_RUNSTEP = make -f ../$(2) $(3)
922d4c3b 253mal_RUNSTEP = $(call $(MAL_IMPL)_RUNSTEP,stepA,$(call $(MAL_IMPL)_STEP_TO_PROG,stepA),../$(2),") #"
59d10e1b 254ocaml_RUNSTEP = ../$(2) $(3)
47699629 255matlab_RUNSTEP = $(matlab_cmd) "$($(1))($(call matlab_args,$(3)));quit;"
c1fe72ae 256miniMAL_RUNSTEP = miniMAL ../$(2) $(3)
dbac60df 257nim_RUNSTEP = ../$(2) $(3)
2faae94c 258objc_RUNSTEP = ../$(2) $(3)
0067158f 259objpascal_RUNSTEP = ../$(2) $(3)
82acd3de 260perl_RUNSTEP = perl ../$(2) $(3)
db4c329a 261php_RUNSTEP = php ../$(2) $(3)
406761e7 262ps_RUNSTEP = gs -q -I./ -dNODISPLAY -- ../$(2) $(3)
db4c329a 263python_RUNSTEP = $(PYTHON) ../$(2) $(3)
4d1456b9 264r_RUNSTEP = Rscript ../$(2) $(3)
f5223195 265racket_RUNSTEP = ../$(2) $(3)
80320efc 266rpython_RUNSTEP = ../$(2) $(3)
db4c329a 267ruby_RUNSTEP = ruby ../$(2) $(3)
abdd56eb 268rust_RUNSTEP = ../$(2) $(3)
821930db 269scala_RUNSTEP = sbt 'run-main $($(1))$(if $(3), $(3),)'
2539e6af 270swift_RUNSTEP = ../$(2) $(3)
0eace3df 271swift3_RUNSTEP = ../$(2) $(3)
576ef370 272tcl_RUNSTEP = tclsh ../$(2) --raw $(3)
ee7cd585 273vb_RUNSTEP = mono ../$(2) --raw $(3)
50a964ce 274vimscript_RUNSTEP = ./run_vimscript.sh ../$(2) $(3)
db4c329a 275
31690700 276
4959b19d
JM
277# DOCKERIZE utility functions
278lc = $(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))))))))))))))))))))))))))
279impl_to_image = kanaka/mal-test-$(call lc,$(1))
280
281actual_impl = $(if $(filter mal,$(1)),$(MAL_IMPL),$(1))
282
283get_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)) ,)
284get_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
287vimscript_TEST_OPTS = --test-timeout 30
288ifeq ($(MAL_IMPL),vimscript)
289mal_TEST_OPTS = --start-timeout 60 --test-timeout 180
290endif
31690700
JM
291
292# Derived lists
293STEPS = $(sort $(filter step%,$(.VARIABLES)))
8569b2af
JM
294DO_IMPLS = $(filter-out $(SKIP_IMPLS),$(IMPLS))
295IMPL_TESTS = $(foreach impl,$(DO_IMPLS),test^$(impl))
31690700 296STEP_TESTS = $(foreach step,$(STEPS),test^$(step))
17180e85 297ALL_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
302DOCKER_BUILD = $(foreach impl,$(DO_IMPLS),docker-build^$(impl))
303
17180e85 304IMPL_PERF = $(foreach impl,$(filter-out $(PERF_EXCLUDES),$(DO_IMPLS)),perf^$(impl))
db4c329a 305
854cf2a6
DM
306IMPL_REPL = $(foreach impl,$(DO_IMPLS),repl^$(impl))
307ALL_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
349test: $(ALL_TESTS)
350tests: $(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
363dist: $(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
377docker-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
391perf: $(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
429define 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
441endef
442
443recur_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)))