miniMAL, perl: add native hash-map equality.
[jackhill/mal.git] / Makefile
CommitLineData
31690700
JM
1#
2# Command line settings
3#
4
5MAL_IMPL = js
6
a05f7822
JM
7PYTHON = python
8
337c8031
JM
9# Extra options to pass to runtest.py
10TEST_OPTS =
11
12# Extra implementation specific options to pass to runtest.py
13mal_TEST_OPTS = --start-timeout 60 --test-timeout 120
14
31690700
JM
15#
16# Settings
17#
18
51c2c1fe 19IMPLS = awk bash c clojure coffee cpp crystal cs erlang elixir es6 factor forth fsharp go groovy \
105c46f1 20 guile haskell java julia js kotlin lua make mal ocaml matlab miniMAL nim \
54d9903c 21 perl php ps python r racket rpython ruby rust scala swift tcl vb vimscript
31690700
JM
22
23step0 = step0_repl
24step1 = step1_read_print
25step2 = step2_eval
26step3 = step3_env
27step4 = step4_if_fn_do
28step5 = step5_tco
29step6 = step6_file
30step7 = step7_quote
31step8 = step8_macros
01c97316 32step9 = step9_try
90f618cb 33stepA = stepA_mal
31690700 34
3b7ef8c7 35EXCLUDE_TESTS += test^awk^step5 # completes at 10,000
cc021efe
JM
36EXCLUDE_TESTS += test^bash^step5 # no stack exhaustion or completion
37EXCLUDE_TESTS += test^c^step5 # segfault
0fbd1b81 38EXCLUDE_TESTS += test^cpp^step5 # completes at 10,000
cc021efe 39EXCLUDE_TESTS += test^cs^step5 # fatal stack overflow fault
e07b9830 40EXCLUDE_TESTS += test^erlang^step5 # erlang is TCO, test passes
d88bc831 41EXCLUDE_TESTS += test^elixir^step5 # elixir is TCO, test passes
8862f80e 42EXCLUDE_TESTS += test^fsharp^step5 # completes at 10,000, fatal stack overflow at 100,000
7907cd90 43EXCLUDE_TESTS += test^haskell^step5 # test completes
cc021efe
JM
44EXCLUDE_TESTS += test^make^step5 # no TCO capability/step
45EXCLUDE_TESTS += test^mal^step5 # no TCO capability/step
dbac60df
JM
46EXCLUDE_TESTS += test^miniMAL^step5 # strange error with runtest.py
47EXCLUDE_TESTS += test^nim^step5 # test completes, even at 100,000
17e1c5f9 48EXCLUDE_TESTS += test^go^step5 # test completes, even at 100,000
cc021efe 49EXCLUDE_TESTS += test^php^step5 # test completes, even at 100,000
7907cd90 50EXCLUDE_TESTS += test^racket^step5 # test completes
cc021efe 51EXCLUDE_TESTS += test^ruby^step5 # test completes, even at 100,000
a77e2b31 52EXCLUDE_TESTS += test^rust^step5 # no catching stack overflows
44d4e31f 53EXCLUDE_TESTS += test^ocaml^step5 # test completes, even at 1,000,000
dbac60df 54EXCLUDE_TESTS += test^vb^step5 # completes at 10,000
725ee0bd 55EXCLUDE_TESTS += test^crystal^step5 # test completes, even at 1,000,000
cc021efe 56
db4c329a 57EXCLUDE_PERFS = perf^mal # TODO: fix this
31690700
JM
58
59#
60# Utility functions
61#
62
63STEP_TEST_FILES = $(strip $(wildcard $(1)/tests/$($(2)).mal) $(wildcard tests/$($(2)).mal))
64
3b7ef8c7 65awk_STEP_TO_PROG = awk/$($(1)).awk
db4c329a
JM
66bash_STEP_TO_PROG = bash/$($(1)).sh
67c_STEP_TO_PROG = c/$($(1))
31690700 68clojure_STEP_TO_PROG = clojure/src/$($(1)).clj
891c3f3b 69coffee_STEP_TO_PROG = coffee/$($(1)).coffee
9ddaa0b9 70cpp_STEP_TO_PROG = cpp/$($(1))
86fe6314 71crystal_STEP_TO_PROG = crystal/$($(1))
db4c329a 72cs_STEP_TO_PROG = cs/$($(1)).exe
51c2c1fe 73elixir_STEP_TO_PROG = elixir/lib/mix/tasks/$($(1)).ex
2cc3804b 74erlang_STEP_TO_PROG = erlang/$($(1))
4eb71990 75es6_STEP_TO_PROG = es6/build/$($(1)).js
199b1ce7 76factor_STEP_TO_PROG = factor/$($(1))/$($(1)).factor
59038a10 77forth_STEP_TO_PROG = forth/$($(1)).fs
1c358979 78fsharp_STEP_TO_PROG = fsharp/$($(1)).exe
69b4abd6 79go_STEP_TO_PROG = go/$($(1))
a9cd6543 80groovy_STEP_TO_PROG = groovy/$($(1)).groovy
db4c329a 81java_STEP_TO_PROG = java/src/main/java/mal/$($(1)).java
b76aa73b 82haskell_STEP_TO_PROG = haskell/$($(1))
a23e0cdb 83julia_STEP_TO_PROG = julia/$($(1)).jl
db4c329a 84js_STEP_TO_PROG = js/$($(1)).js
53c2ea70 85kotlin_STEP_TO_PROG = kotlin/$($(1)).jar
9d42904e 86lua_STEP_TO_PROG = lua/$($(1)).lua
db4c329a
JM
87make_STEP_TO_PROG = make/$($(1)).mk
88mal_STEP_TO_PROG = mal/$($(1)).mal
59d10e1b 89ocaml_STEP_TO_PROG = ocaml/$($(1))
9a54ea18 90matlab_STEP_TO_PROG = matlab/$($(1)).m
c1fe72ae 91miniMAL_STEP_TO_PROG = miniMAL/$($(1)).json
dbac60df 92nim_STEP_TO_PROG = nim/$($(1))
b5dedee0 93perl_STEP_TO_PROG = perl/$($(1)).pl
db4c329a
JM
94php_STEP_TO_PROG = php/$($(1)).php
95ps_STEP_TO_PROG = ps/$($(1)).ps
96python_STEP_TO_PROG = python/$($(1)).py
4d1456b9 97r_STEP_TO_PROG = r/$($(1)).r
f5223195 98racket_STEP_TO_PROG = racket/$($(1)).rkt
80320efc 99rpython_STEP_TO_PROG = rpython/$($(1))
db4c329a 100ruby_STEP_TO_PROG = ruby/$($(1)).rb
434516e0 101rust_STEP_TO_PROG = rust/target/release/$($(1))
821930db 102scala_STEP_TO_PROG = scala/$($(1)).scala
2539e6af 103swift_STEP_TO_PROG = swift/$($(1))
54d9903c 104tcl_STEP_TO_PROG = tcl/$($(1)).tcl
ee7cd585 105vb_STEP_TO_PROG = vb/$($(1)).exe
50a964ce 106vimscript_STEP_TO_PROG = vimscript/$($(1)).vim
5eb1f5cb 107guile_STEP_TO_PROG = guile/$($(1)).scm
db4c329a 108
c4033aab
JM
109# Needed some argument munging
110COMMA = ,
111noop =
112SPACE = $(noop) $(noop)
d1596ac2 113export FACTOR_ROOTS := .
db4c329a 114
3b7ef8c7 115awk_RUNSTEP = awk -O -f ../$(2) $(3)
db4c329a
JM
116bash_RUNSTEP = bash ../$(2) $(3)
117c_RUNSTEP = ../$(2) $(3)
118clojure_RUNSTEP = lein with-profile +$(1) trampoline run $(3)
891c3f3b 119coffee_RUNSTEP = coffee ../$(2) $(3)
9ddaa0b9 120cpp_RUNSTEP = ../$(2) $(3)
86fe6314 121crystal_RUNSTEP = ../$(2) $(3)
db4c329a 122cs_RUNSTEP = mono ../$(2) --raw $(3)
df2ca97b 123elixir_RUNSTEP = mix $(notdir $(basename $(2))) $(3)
2cc3804b 124erlang_RUNSTEP = ../$(2) $(3)
4eb71990 125es6_RUNSTEP = node ../$(2) $(3)
389c9b8a 126factor_RUNSTEP = factor ../$(2) $(3)
59038a10 127forth_RUNSTEP = gforth ../$(2) $(3)
1c358979 128fsharp_RUNSTEP = mono ../$(2) --raw $(3)
69b4abd6 129go_RUNSTEP = ../$(2) $(3)
a9cd6543 130groovy_RUNSTEP = groovy ../$(2) $(3)
b76aa73b 131haskell_RUNSTEP = ../$(2) $(3)
798206ac 132java_RUNSTEP = mvn -quiet exec:java -Dexec.mainClass="mal.$($(1))" $(if $(3), -Dexec.args="$(3)",)
a23e0cdb 133julia_RUNSTEP = ../$(2) $(3)
db4c329a 134js_RUNSTEP = node ../$(2) $(3)
53c2ea70 135kotlin_RUNSTEP = java -jar ../$(2) $(3)
798206ac 136lua_RUNSTEP = ../$(2) $(3)
db4c329a 137make_RUNSTEP = make -f ../$(2) $(3)
922d4c3b 138mal_RUNSTEP = $(call $(MAL_IMPL)_RUNSTEP,stepA,$(call $(MAL_IMPL)_STEP_TO_PROG,stepA),../$(2),") #"
59d10e1b 139ocaml_RUNSTEP = ../$(2) $(3)
7f567f36
JM
140matlab_args = $(subst $(SPACE),$(COMMA),$(foreach x,$(strip $(1)),'$(x)'))
141matlab_RUNSTEP = matlab -nodisplay -nosplash -nodesktop -nojvm -r "$($(1))($(call matlab_args,$(3)));quit;"
c1fe72ae 142miniMAL_RUNSTEP = miniMAL ../$(2) $(3)
dbac60df 143nim_RUNSTEP = ../$(2) $(3)
82acd3de 144perl_RUNSTEP = perl ../$(2) $(3)
db4c329a 145php_RUNSTEP = php ../$(2) $(3)
406761e7 146ps_RUNSTEP = gs -q -I./ -dNODISPLAY -- ../$(2) $(3)
db4c329a 147python_RUNSTEP = $(PYTHON) ../$(2) $(3)
4d1456b9 148r_RUNSTEP = Rscript ../$(2) $(3)
f5223195 149racket_RUNSTEP = ../$(2) $(3)
80320efc 150rpython_RUNSTEP = ../$(2) $(3)
db4c329a 151ruby_RUNSTEP = ruby ../$(2) $(3)
abdd56eb 152rust_RUNSTEP = ../$(2) $(3)
821930db 153scala_RUNSTEP = sbt 'run-main $($(1))$(if $(3), $(3),)'
2539e6af 154swift_RUNSTEP = ../$(2) $(3)
576ef370 155tcl_RUNSTEP = tclsh ../$(2) --raw $(3)
ee7cd585 156vb_RUNSTEP = mono ../$(2) --raw $(3)
50a964ce 157vimscript_RUNSTEP = ./run_vimscript.sh ../$(2) $(3)
5eb1f5cb 158# needs TERM=dumb to work with readline
337c8031 159guile_RUNSTEP = guile --no-auto-compile -L ../guile ../$(2) $(3)
db4c329a 160
31690700 161
50a964ce
DM
162vimscript_TEST_OPTS = --test-timeout 30
163ifeq ($(MAL_IMPL),vimscript)
164mal_TEST_OPTS = --start-timeout 60 --test-timeout 180
165endif
31690700
JM
166
167# Derived lists
168STEPS = $(sort $(filter step%,$(.VARIABLES)))
8569b2af
JM
169DO_IMPLS = $(filter-out $(SKIP_IMPLS),$(IMPLS))
170IMPL_TESTS = $(foreach impl,$(DO_IMPLS),test^$(impl))
31690700
JM
171STEP_TESTS = $(foreach step,$(STEPS),test^$(step))
172ALL_TESTS = $(filter-out $(EXCLUDE_TESTS),\
173 $(strip $(sort \
8569b2af 174 $(foreach impl,$(DO_IMPLS),\
31690700
JM
175 $(foreach step,$(STEPS),test^$(impl)^$(step))))))
176
8569b2af
JM
177IMPL_STATS = $(foreach impl,$(DO_IMPLS),stats^$(impl))
178IMPL_STATS_LISP = $(foreach impl,$(DO_IMPLS),stats-lisp^$(impl))
31690700 179
cf1d3eae
JM
180DOCKER_BUILD = $(foreach impl,$(DO_IMPLS),docker-build^$(impl))
181
8569b2af 182IMPL_PERF = $(filter-out $(EXCLUDE_PERFS),$(foreach impl,$(DO_IMPLS),perf^$(impl)))
db4c329a 183
31690700
JM
184#
185# Build rules
186#
187
4fc7a281
JM
188# Build a program in an implementation directory
189$(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),$(call $(i)_STEP_TO_PROG,$(s)))):
9ddaa0b9
ST
190 $(MAKE) -C $(dir $(@)) $(notdir $(@))
191
31690700
JM
192# Allow test, test^STEP, test^IMPL, and test^IMPL^STEP
193.SECONDEXPANSION:
194$(IMPL_TESTS): $$(filter $$@^%,$$(ALL_TESTS))
195
196.SECONDEXPANSION:
197$(STEP_TESTS): $$(foreach step,$$(subst test^,,$$@),$$(filter %^$$(step),$$(ALL_TESTS)))
198
199.SECONDEXPANSION:
200$(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@))))
201 @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
202 $(foreach step,$(word 3,$(subst ^, ,$(@))),\
203 cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \
204 $(foreach test,$(call STEP_TEST_FILES,$(impl),$(step)),\
205 echo '----------------------------------------------'; \
206 echo 'Testing $@, step file: $+, test file: $(test)'; \
fc4c7889
JM
207 echo 'Running: ../runtest.py $(TEST_OPTS) $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+))'; \
208 ../runtest.py $(TEST_OPTS) $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+));)))
31690700
JM
209
210test: $(ALL_TESTS)
211tests: $(ALL_TESTS)
212
213
214# Stats rules
215
db4c329a
JM
216stats: $(IMPL_STATS)
217stats-lisp: $(IMPL_STATS_LISP)
218
31690700
JM
219.SECONDEXPANSION:
220$(IMPL_STATS):
221 @echo "----------------------------------------------"; \
222 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
223 echo "Stats for $(impl):"; \
224 $(MAKE) --no-print-directory -C $(impl) stats)
225
712af9ef
JM
226.SECONDEXPANSION:
227$(IMPL_STATS_LISP):
228 @echo "----------------------------------------------"; \
229 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
230 echo "Stats (lisp only) for $(impl):"; \
231 $(MAKE) --no-print-directory -C $(impl) stats-lisp)
232
cf1d3eae
JM
233# Docker build rules
234
235docker-build: $(DOCKER_BUILD)
236
237.SECONDEXPANSION:
238$(DOCKER_BUILD):
239 echo "----------------------------------------------"; \
240 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
f7824465
JM
241 echo "Running: docker build -t kanaka/mal-test-$(impl) .:"; \
242 cd $(impl) && docker build -t kanaka/mal-test-$(impl) .)
db4c329a
JM
243
244# Performance test rules
245
246perf: $(IMPL_PERF)
247
248.SECONDEXPANSION:
249$(IMPL_PERF):
250 @echo "----------------------------------------------"; \
251 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
252 cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \
253 echo "Performance test for $(impl):"; \
254 echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal)'; \
255 $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal); \
256 echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal)'; \
699f0ad2
JM
257 $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal); \
258 echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf3.mal)'; \
259 $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf3.mal))