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