ada2: rename to ada.2
[jackhill/mal.git] / Makefile
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 'make TEST_OPTS="--opt ..." # options to pass to runtest.py'
36 @echo
37 @echo 'Other:'
38 @echo
39 @echo 'make "docker-build^IMPL" # build docker image for IMPL'
40 @echo
41 @echo 'make "docker-shell^IMPL" # start bash shell in docker image for IMPL'
42 @echo
43
44 #
45 # Command line settings
46 #
47
48 MAL_IMPL = js
49
50 # cbm or qbasic
51 basic_MODE = cbm
52 # clj or cljs (Clojure vs ClojureScript/lumo)
53 clojure_MODE = clj
54 # python, js, cpp, or neko
55 haxe_MODE = neko
56 # octave or matlab
57 matlab_MODE = octave
58 # python, python2 or python3
59 python_MODE = python
60 # scheme (chibi, kawa, gauche, chicken, sagittarius, cyclone, foment)
61 scheme_MODE = chibi
62 # js wace_libc wace_fooboot
63 wasm_MODE = wace_libc
64
65 # Extra options to pass to runtest.py
66 TEST_OPTS =
67
68 # Test with previous test files not just the test files for the
69 # current step. Step 0 and 1 tests are special and not included in
70 # later steps.
71 REGRESS =
72
73 DEFERRABLE=1
74 OPTIONAL=1
75
76 # Run target/rule within docker image for the implementation
77 DOCKERIZE =
78
79
80 #
81 # Implementation specific settings
82 #
83
84 IMPLS = ada ada.2 awk bash basic c chuck clojure coffee common-lisp cpp crystal cs d dart \
85 elisp elixir elm erlang es6 factor fantom forth fsharp go groovy gnu-smalltalk \
86 guile haskell haxe hy io java js julia kotlin livescript logo lua make mal \
87 matlab miniMAL nasm nim objc objpascal ocaml perl perl6 php picolisp plpgsql \
88 plsql powershell ps python r racket rexx rpython ruby rust scala scheme skew \
89 swift swift3 swift4 tcl ts vb vhdl vimscript wasm yorick
90
91 EXTENSION = .mal
92
93 step0 = step0_repl
94 step1 = step1_read_print
95 step2 = step2_eval
96 step3 = step3_env
97 step4 = step4_if_fn_do
98 step5 = step5_tco
99 step6 = step6_file
100 step7 = step7_quote
101 step8 = step8_macros
102 step9 = step9_try
103 stepA = stepA_mal
104
105 argv_STEP = step6_file
106
107
108 regress_step0 = step0
109 regress_step1 = step1
110 regress_step2 = step2
111 regress_step3 = $(regress_step2) step3
112 regress_step4 = $(regress_step3) step4
113 regress_step5 = $(regress_step4) step5
114 regress_step6 = $(regress_step5) step6
115 regress_step7 = $(regress_step6) step7
116 regress_step8 = $(regress_step7) step8
117 regress_step9 = $(regress_step8) step9
118 regress_stepA = $(regress_step9) stepA
119
120 step5_EXCLUDES += bash # never completes at 10,000
121 step5_EXCLUDES += basic # too slow, and limited to ints of 2^16
122 step5_EXCLUDES += logo # too slow for 10,000
123 step5_EXCLUDES += make # no TCO capability (iteration or recursion)
124 step5_EXCLUDES += mal # host impl dependent
125 step5_EXCLUDES += matlab # never completes at 10,000
126 step5_EXCLUDES += plpgsql # too slow for 10,000
127 step5_EXCLUDES += plsql # too slow for 10,000
128 step5_EXCLUDES += powershell # too slow for 10,000
129 step5_EXCLUDES += $(if $(filter cpp,$(haxe_MODE)),haxe,) # cpp finishes 10,000, segfaults at 100,000
130
131 dist_EXCLUDES += mal
132 # TODO: still need to implement dist
133 dist_EXCLUDES += guile io julia matlab swift
134
135
136 # Extra options to pass to runtest.py
137 logo_TEST_OPTS = --start-timeout 60 --test-timeout 120
138 mal_TEST_OPTS = --start-timeout 60 --test-timeout 120
139 miniMAL_TEST_OPTS = --start-timeout 60 --test-timeout 120
140 perl6_TEST_OPTS = --test-timeout=60
141 plpgsql_TEST_OPTS = --start-timeout 60 --test-timeout 180
142 plsql_TEST_OPTS = --start-timeout 120 --test-timeout 120
143 vimscript_TEST_OPTS = --test-timeout 30
144 ifeq ($(MAL_IMPL),vimscript)
145 mal_TEST_OPTS = --start-timeout 60 --test-timeout 180
146 else ifeq ($(MAL_IMPL),powershell)
147 mal_TEST_OPTS = --start-timeout 60 --test-timeout 180
148 endif
149
150
151 #
152 # Implementation specific utility functions
153 #
154
155 basic_STEP_TO_PROG_cbm = basic/$($(1)).bas
156 basic_STEP_TO_PROG_qbasic = basic/$($(1))
157
158 clojure_STEP_TO_PROG_clj = clojure/target/$($(1)).jar
159 clojure_STEP_TO_PROG_cljs = clojure/src/mal/$($(1)).cljc
160
161 haxe_STEP_TO_PROG_neko = haxe/$($(1)).n
162 haxe_STEP_TO_PROG_python = haxe/$($(1)).py
163 haxe_STEP_TO_PROG_cpp = haxe/cpp/$($(1))
164 haxe_STEP_TO_PROG_js = haxe/$($(1)).js
165
166 scheme_STEP_TO_PROG_chibi = scheme/$($(1)).scm
167 scheme_STEP_TO_PROG_kawa = scheme/out/$($(1)).class
168 scheme_STEP_TO_PROG_gauche = scheme/$($(1)).scm
169 scheme_STEP_TO_PROG_chicken = scheme/$($(1))
170 scheme_STEP_TO_PROG_sagittarius = scheme/$($(1)).scm
171 scheme_STEP_TO_PROG_cyclone = scheme/$($(1))
172 scheme_STEP_TO_PROG_foment = scheme/$($(1)).scm
173
174 # Map of step (e.g. "step8") to executable file for that step
175 ada_STEP_TO_PROG = ada/$($(1))
176 ada.2_STEP_TO_PROG = ada.2/$($(1))
177 awk_STEP_TO_PROG = awk/$($(1)).awk
178 bash_STEP_TO_PROG = bash/$($(1)).sh
179 basic_STEP_TO_PROG = $(basic_STEP_TO_PROG_$(basic_MODE))
180 c_STEP_TO_PROG = c/$($(1))
181 chuck_STEP_TO_PROG = chuck/$($(1)).ck
182 clojure_STEP_TO_PROG = $(clojure_STEP_TO_PROG_$(clojure_MODE))
183 coffee_STEP_TO_PROG = coffee/$($(1)).coffee
184 common-lisp_STEP_TO_PROG = common-lisp/$($(1))
185 cpp_STEP_TO_PROG = cpp/$($(1))
186 crystal_STEP_TO_PROG = crystal/$($(1))
187 cs_STEP_TO_PROG = cs/$($(1)).exe
188 d_STEP_TO_PROG = d/$($(1))
189 dart_STEP_TO_PROG = dart/$($(1)).dart
190 elisp_STEP_TO_PROG = elisp/$($(1)).el
191 elixir_STEP_TO_PROG = elixir/lib/mix/tasks/$($(1)).ex
192 elm_STEP_TO_PROG = elm/$($(1)).js
193 erlang_STEP_TO_PROG = erlang/$($(1))
194 es6_STEP_TO_PROG = es6/$($(1)).mjs
195 factor_STEP_TO_PROG = factor/$($(1))/$($(1)).factor
196 fantom_STEP_TO_PROG = fantom/lib/fan/$($(1)).pod
197 forth_STEP_TO_PROG = forth/$($(1)).fs
198 fsharp_STEP_TO_PROG = fsharp/$($(1)).exe
199 go_STEP_TO_PROG = go/$($(1))
200 groovy_STEP_TO_PROG = groovy/$($(1)).groovy
201 gnu-smalltalk_STEP_TO_PROG = gnu-smalltalk/$($(1)).st
202 guile_STEP_TO_PROG = guile/$($(1)).scm
203 haskell_STEP_TO_PROG = haskell/$($(1))
204 haxe_STEP_TO_PROG = $(haxe_STEP_TO_PROG_$(haxe_MODE))
205 hy_STEP_TO_PROG = hy/$($(1)).hy
206 io_STEP_TO_PROG = io/$($(1)).io
207 java_STEP_TO_PROG = java/target/classes/mal/$($(1)).class
208 js_STEP_TO_PROG = js/$($(1)).js
209 julia_STEP_TO_PROG = julia/$($(1)).jl
210 kotlin_STEP_TO_PROG = kotlin/$($(1)).jar
211 livescript_STEP_TO_PROG = livescript/$($(1)).js
212 logo_STEP_TO_PROG = logo/$($(1)).lg
213 lua_STEP_TO_PROG = lua/$($(1)).lua
214 make_STEP_TO_PROG = make/$($(1)).mk
215 mal_STEP_TO_PROG = mal/$($(1)).mal
216 matlab_STEP_TO_PROG = matlab/$($(1)).m
217 miniMAL_STEP_TO_PROG = miniMAL/$($(1)).json
218 nasm_STEP_TO_PROG = nasm/$($(1))
219 nim_STEP_TO_PROG = nim/$($(1))
220 objc_STEP_TO_PROG = objc/$($(1))
221 objpascal_STEP_TO_PROG = objpascal/$($(1))
222 ocaml_STEP_TO_PROG = ocaml/$($(1))
223 perl_STEP_TO_PROG = perl/$($(1)).pl
224 perl6_STEP_TO_PROG = perl6/$($(1)).pl
225 php_STEP_TO_PROG = php/$($(1)).php
226 picolisp_STEP_TO_PROG = picolisp/$($(1)).l
227 plpgsql_STEP_TO_PROG = plpgsql/$($(1)).sql
228 plsql_STEP_TO_PROG = plsql/$($(1)).sql
229 powershell_STEP_TO_PROG = powershell/$($(1)).ps1
230 ps_STEP_TO_PROG = ps/$($(1)).ps
231 python_STEP_TO_PROG = python/$($(1)).py
232 r_STEP_TO_PROG = r/$($(1)).r
233 racket_STEP_TO_PROG = racket/$($(1)).rkt
234 rexx_STEP_TO_PROG = rexx/$($(1)).rexxpp
235 rpython_STEP_TO_PROG = rpython/$($(1))
236 ruby_STEP_TO_PROG = ruby/$($(1)).rb
237 rust_STEP_TO_PROG = rust/$($(1))
238 scala_STEP_TO_PROG = scala/target/scala-2.11/classes/$($(1)).class
239 scheme_STEP_TO_PROG = $(scheme_STEP_TO_PROG_$(scheme_MODE))
240 skew_STEP_TO_PROG = skew/$($(1)).js
241 swift_STEP_TO_PROG = swift/$($(1))
242 swift3_STEP_TO_PROG = swift3/$($(1))
243 swift4_STEP_TO_PROG = swift4/$($(1))
244 tcl_STEP_TO_PROG = tcl/$($(1)).tcl
245 ts_STEP_TO_PROG = ts/$($(1)).js
246 vb_STEP_TO_PROG = vb/$($(1)).exe
247 vhdl_STEP_TO_PROG = vhdl/$($(1))
248 vimscript_STEP_TO_PROG = vimscript/$($(1)).vim
249 wasm_STEP_TO_PROG = wasm/$($(1)).wasm
250 yorick_STEP_TO_PROG = yorick/$($(1)).i
251
252
253 #
254 # General settings and utility functions
255 #
256
257 # Needed some argument munging
258 COMMA = ,
259 noop =
260 SPACE = $(noop) $(noop)
261 export FACTOR_ROOTS := .
262
263 opt_DEFERRABLE = $(if $(strip $(DEFERRABLE)),$(if $(filter t true T True TRUE 1 y yes Yes YES,$(DEFERRABLE)),--deferrable,--no-deferrable),--no-deferrable)
264 opt_OPTIONAL = $(if $(strip $(OPTIONAL)),$(if $(filter t true T True TRUE 1 y yes Yes YES,$(OPTIONAL)),--optional,--no-optional),--no-optional)
265
266 # Return list of test files for a given step. If REGRESS is set then
267 # test files will include step 2 tests through tests for the step
268 # being tested.
269 STEP_TEST_FILES = $(strip $(wildcard \
270 $(foreach s,$(if $(strip $(REGRESS)),\
271 $(filter-out $(if $(filter $(1),$(step5_EXCLUDES)),step5,),\
272 $(regress_$(2)))\
273 ,$(2)),\
274 $(1)/tests/$($(s))$(EXTENSION) tests/$($(s))$(EXTENSION))))
275
276 # DOCKERIZE utility functions
277 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))))))))))))))))))))))))))
278 impl_to_image = kanaka/mal-test-$(call lc,$(1))
279
280 actual_impl = $(if $(filter mal,$(1)),$(MAL_IMPL),$(1))
281
282 # Takes impl
283 # Returns nothing if DOCKERIZE is not set, otherwise returns the
284 # docker prefix necessary to run make within the docker environment
285 # for this impl
286 get_build_command = $(strip $(if $(strip $(DOCKERIZE)),\
287 docker run \
288 -it --rm -u $(shell id -u) \
289 -v $(dir $(abspath $(lastword $(MAKEFILE_LIST)))):/mal \
290 -w /mal/$(1) \
291 $(if $(strip $($(1)_MODE)),-e $(1)_MODE=$($(1)_MODE),) \
292 $(if $(filter factor,$(1)),-e FACTOR_ROOTS=$(FACTOR_ROOTS),) \
293 $(call impl_to_image,$(1)) \
294 $(MAKE) $(if $(strip $($(1)_MODE)),$(1)_MODE=$($(1)_MODE),) \
295 ,\
296 $(MAKE) $(if $(strip $($(1)_MODE)),$(1)_MODE=$($(1)_MODE),)))
297
298 # Takes impl and step args. Optional env vars and dockerize args
299 # Returns a command prefix (docker command and environment variables)
300 # necessary to launch the given impl and step
301 get_run_prefix = $(strip $(if $(strip $(DOCKERIZE) $(4)),\
302 docker run -e STEP=$($2) -e MAL_IMPL=$(MAL_IMPL) \
303 -it --rm -u $(shell id -u) \
304 -v $(dir $(abspath $(lastword $(MAKEFILE_LIST)))):/mal \
305 -w /mal/$(call actual_impl,$(1)) \
306 $(if $(strip $($(1)_MODE)),-e $(1)_MODE=$($(1)_MODE),) \
307 $(if $(filter factor,$(1)),-e FACTOR_ROOTS=$(FACTOR_ROOTS),) \
308 $(foreach env,$(3),-e $(env)) \
309 $(call impl_to_image,$(call actual_impl,$(1))) \
310 ,\
311 env STEP=$($2) MAL_IMPL=$(MAL_IMPL) \
312 $(if $(strip $($(1)_MODE)),$(1)_MODE=$($(1)_MODE),) \
313 $(if $(filter factor,$(1)),FACTOR_ROOTS=$(FACTOR_ROOTS),) \
314 $(3)))
315
316 # Takes impl and step
317 # Returns the runtest command prefix (with runtest options) for testing the given step
318 get_runtest_cmd = $(call get_run_prefix,$(1),$(2),$(if $(filter cs fsharp tcl vb,$(1)),RAW=1,)) \
319 ../runtest.py $(opt_DEFERRABLE) $(opt_OPTIONAL) $(call $(1)_TEST_OPTS) $(TEST_OPTS)
320
321 # Takes impl and step
322 # Returns the runtest command prefix (with runtest options) for testing the given step
323 get_argvtest_cmd = $(call get_run_prefix,$(1),$(2)) ../run_argv_test.sh
324
325 # Derived lists
326 STEPS = $(sort $(filter-out %_EXCLUDES,$(filter step%,$(.VARIABLES))))
327 DO_IMPLS = $(filter-out $(SKIP_IMPLS),$(IMPLS))
328 IMPL_TESTS = $(foreach impl,$(DO_IMPLS),test^$(impl))
329 STEP_TESTS = $(foreach step,$(STEPS),test^$(step))
330 ALL_TESTS = $(filter-out $(foreach e,$(step5_EXCLUDES),test^$(e)^step5),\
331 $(strip $(sort \
332 $(foreach impl,$(DO_IMPLS),\
333 $(foreach step,$(STEPS),test^$(impl)^$(step))))))
334
335 DOCKER_BUILD = $(foreach impl,$(DO_IMPLS),docker-build^$(impl))
336
337 DOCKER_SHELL = $(foreach impl,$(DO_IMPLS),docker-shell^$(impl))
338
339 IMPL_PERF = $(foreach impl,$(filter-out $(perf_EXCLUDES),$(DO_IMPLS)),perf^$(impl))
340
341 IMPL_REPL = $(foreach impl,$(DO_IMPLS),repl^$(impl))
342 ALL_REPL = $(strip $(sort \
343 $(foreach impl,$(DO_IMPLS),\
344 $(foreach step,$(STEPS),repl^$(impl)^$(step)))))
345
346
347 #
348 # Build rules
349 #
350
351 # Enable secondary expansion for all rules
352 .SECONDEXPANSION:
353
354 # Build a program in an implementation directory
355 # Make sure we always try and build first because the dependencies are
356 # encoded in the implementation Makefile not here
357 .PHONY: $(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),$(call $(i)_STEP_TO_PROG,$(s))))
358 $(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),$(call $(i)_STEP_TO_PROG,$(s)))):
359 $(foreach impl,$(word 1,$(subst /, ,$(@))),\
360 $(if $(DOCKERIZE), \
361 $(call get_build_command,$(impl)) $(patsubst $(impl)/%,%,$(@)), \
362 $(call get_build_command,$(impl)) -C $(impl) $(subst $(impl)/,,$(@))))
363
364 # Allow IMPL, and IMPL^STEP
365 $(DO_IMPLS): $$(foreach s,$$(STEPS),$$(call $$(@)_STEP_TO_PROG,$$(s)))
366
367 $(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),$(i)^$(s))): $$(call $$(word 1,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 2,$$(subst ^, ,$$(@))))
368
369
370 #
371 # Test rules
372 #
373
374 $(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@))))
375 @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
376 $(foreach step,$(word 3,$(subst ^, ,$(@))),\
377 cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)) && \
378 $(foreach test,$(call STEP_TEST_FILES,$(impl),$(step)),\
379 echo '----------------------------------------------' && \
380 echo 'Testing $@; step file: $+, test file: $(test)' && \
381 echo 'Running: $(call get_runtest_cmd,$(impl),$(step)) ../$(test) -- ../$(impl)/run' && \
382 $(call get_runtest_cmd,$(impl),$(step)) ../$(test) -- ../$(impl)/run && \
383 $(if $(filter tests/$(argv_STEP)$(EXTENSION),$(test)),\
384 echo '----------------------------------------------' && \
385 echo 'Testing ARGV of $@; step file: $+' && \
386 echo 'Running: $(call get_argvtest_cmd,$(impl),$(step)) ../$(impl)/run ' && \
387 $(call get_argvtest_cmd,$(impl),$(step)) ../$(impl)/run && ,\
388 true && ))\
389 true))
390
391 # Allow test, tests, test^STEP, test^IMPL, and test^IMPL^STEP
392 test: $(ALL_TESTS)
393 tests: $(ALL_TESTS)
394
395 $(IMPL_TESTS): $$(filter $$@^%,$$(ALL_TESTS))
396
397 $(STEP_TESTS): $$(foreach step,$$(subst test^,,$$@),$$(filter %^$$(step),$$(ALL_TESTS)))
398
399
400 #
401 # Docker build rules
402 #
403
404 docker-build: $(DOCKER_BUILD)
405
406 $(DOCKER_BUILD):
407 @echo "----------------------------------------------"; \
408 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
409 echo "Running: docker build -t $(call impl_to_image,$(impl)) .:"; \
410 cd $(impl) && docker build -t $(call impl_to_image,$(impl)) .)
411
412 #
413 # Docker shell rules
414 #
415
416 $(DOCKER_SHELL):
417 @echo "----------------------------------------------"; \
418 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
419 echo "Running: $(call get_run_prefix,$(impl),stepA,,dockerize) bash"; \
420 $(call get_run_prefix,$(impl),stepA,,dockerize) bash)
421
422
423 #
424 # Performance test rules
425 #
426
427 perf: $(IMPL_PERF)
428
429 $(IMPL_PERF):
430 @echo "----------------------------------------------"; \
431 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
432 cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \
433 echo "Performance test for $(impl):"; \
434 echo 'Running: $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf1.mal'; \
435 $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf1.mal; \
436 echo 'Running: $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf2.mal'; \
437 $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf2.mal; \
438 echo 'Running: $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf3.mal'; \
439 $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf3.mal)
440
441
442 #
443 # REPL invocation rules
444 #
445
446 $(ALL_REPL): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@))))
447 @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
448 $(foreach step,$(word 3,$(subst ^, ,$(@))),\
449 cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \
450 echo 'REPL implementation $(impl), step file: $+'; \
451 echo 'Running: $(call get_run_prefix,$(impl),$(step)) ../$(impl)/run $(RUN_ARGS)'; \
452 $(call get_run_prefix,$(impl),$(step)) ../$(impl)/run $(RUN_ARGS);))
453
454 # Allow repl^IMPL^STEP and repl^IMPL (which starts REPL of stepA)
455 $(IMPL_REPL): $$@^stepA
456
457 #
458 # Utility functions
459 #
460 print-%:
461 @echo "$($(*))"
462
463 #
464 # Recursive rules (call make FOO in each subdirectory)
465 #
466
467 define recur_template
468 .PHONY: $(1)
469 $(1): $(2)
470 $(2):
471 @echo "----------------------------------------------"; \
472 $$(foreach impl,$$(word 2,$$(subst ^, ,$$(@))),\
473 $$(if $$(DOCKERIZE), \
474 echo "Running: $$(call get_build_command,$$(impl)) --no-print-directory $(1)"; \
475 $$(call get_build_command,$$(impl)) --no-print-directory $(1), \
476 echo "Running: $$(call get_build_command,$$(impl)) --no-print-directory -C $$(impl) $(1)"; \
477 $$(call get_build_command,$$(impl)) --no-print-directory -C $$(impl) $(1)))
478 endef
479
480 recur_impls_ = $(filter-out $(foreach impl,$($(1)_EXCLUDES),$(1)^$(impl)),$(foreach impl,$(IMPLS),$(1)^$(impl)))
481
482 # recursive clean
483 $(eval $(call recur_template,clean,$(call recur_impls_,clean)))
484
485 # recursive stats
486 $(eval $(call recur_template,stats,$(call recur_impls_,stats)))
487 $(eval $(call recur_template,stats-lisp,$(call recur_impls_,stats-lisp)))
488
489 # recursive dist
490 $(eval $(call recur_template,dist,$(call recur_impls_,dist)))