matlab: step7, fix reader bug.
[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
9d42904e 13IMPLS = bash c clojure coffee cs go haskell java js lua make mal \
9a54ea18 14 ocaml matlab perl php ps python r racket ruby rust scala vb
31690700
JM
15
16step0 = step0_repl
17step1 = step1_read_print
18step2 = step2_eval
19step3 = step3_env
20step4 = step4_if_fn_do
21step5 = step5_tco
22step6 = step6_file
23step7 = step7_quote
24step8 = step8_macros
01c97316
JM
25step9 = step9_try
26stepA = stepA_interop
31690700 27
cc021efe
JM
28EXCLUDE_TESTS += test^bash^step5 # no stack exhaustion or completion
29EXCLUDE_TESTS += test^c^step5 # segfault
30EXCLUDE_TESTS += test^cs^step5 # fatal stack overflow fault
31EXCLUDE_TESTS += test^make^step5 # no TCO capability/step
32EXCLUDE_TESTS += test^mal^step5 # no TCO capability/step
17e1c5f9 33EXCLUDE_TESTS += test^go^step5 # test completes, even at 100,000
cc021efe
JM
34EXCLUDE_TESTS += test^php^step5 # test completes, even at 100,000
35EXCLUDE_TESTS += test^ruby^step5 # test completes, even at 100,000
a77e2b31 36EXCLUDE_TESTS += test^rust^step5 # no catching stack overflows
44d4e31f 37EXCLUDE_TESTS += test^ocaml^step5 # test completes, even at 1,000,000
cc021efe
JM
38
39# interop tests now implemented yet
01c97316
JM
40EXCLUDE_TESTS += test^cs^stepA test^java^stepA test^mal^stepA \
41 test^mal^step0 test^php^stepA test^ps^stepA \
42 test^python^stepA test^ruby^stepA
cc021efe 43
db4c329a 44EXCLUDE_PERFS = perf^mal # TODO: fix this
31690700
JM
45
46#
47# Utility functions
48#
49
50STEP_TEST_FILES = $(strip $(wildcard $(1)/tests/$($(2)).mal) $(wildcard tests/$($(2)).mal))
51
db4c329a
JM
52bash_STEP_TO_PROG = bash/$($(1)).sh
53c_STEP_TO_PROG = c/$($(1))
31690700 54clojure_STEP_TO_PROG = clojure/src/$($(1)).clj
891c3f3b 55coffee_STEP_TO_PROG = coffee/$($(1)).coffee
db4c329a 56cs_STEP_TO_PROG = cs/$($(1)).exe
69b4abd6 57go_STEP_TO_PROG = go/$($(1))
db4c329a 58java_STEP_TO_PROG = java/src/main/java/mal/$($(1)).java
b76aa73b 59haskell_STEP_TO_PROG = haskell/$($(1))
db4c329a 60js_STEP_TO_PROG = js/$($(1)).js
9d42904e 61lua_STEP_TO_PROG = lua/$($(1)).lua
db4c329a
JM
62make_STEP_TO_PROG = make/$($(1)).mk
63mal_STEP_TO_PROG = mal/$($(1)).mal
59d10e1b 64ocaml_STEP_TO_PROG = ocaml/$($(1))
9a54ea18 65matlab_STEP_TO_PROG = matlab/$($(1)).m
b5dedee0 66perl_STEP_TO_PROG = perl/$($(1)).pl
db4c329a
JM
67php_STEP_TO_PROG = php/$($(1)).php
68ps_STEP_TO_PROG = ps/$($(1)).ps
69python_STEP_TO_PROG = python/$($(1)).py
4d1456b9 70r_STEP_TO_PROG = r/$($(1)).r
f5223195 71racket_STEP_TO_PROG = racket/$($(1)).rkt
db4c329a 72ruby_STEP_TO_PROG = ruby/$($(1)).rb
abdd56eb 73rust_STEP_TO_PROG = rust/target/$($(1))
821930db 74scala_STEP_TO_PROG = scala/$($(1)).scala
ee7cd585 75vb_STEP_TO_PROG = vb/$($(1)).exe
db4c329a
JM
76
77
78bash_RUNSTEP = bash ../$(2) $(3)
79c_RUNSTEP = ../$(2) $(3)
80clojure_RUNSTEP = lein with-profile +$(1) trampoline run $(3)
891c3f3b 81coffee_RUNSTEP = coffee ../$(2) $(3)
db4c329a 82cs_RUNSTEP = mono ../$(2) --raw $(3)
69b4abd6 83go_RUNSTEP = ../$(2) $(3)
b76aa73b 84haskell_RUNSTEP = ../$(2) $(3)
db4c329a
JM
85java_RUNSTEP = mvn -quiet exec:java -Dexec.mainClass="mal.$($(1))" -Dexec.args="--raw$(if $(3), $(3),)"
86js_RUNSTEP = node ../$(2) $(3)
9d42904e 87lua_RUNSTEP = ../$(2) $(3)
db4c329a
JM
88make_RUNSTEP = make -f ../$(2) $(3)
89mal_RUNSTEP = $(call $(MAL_IMPL)_RUNSTEP,$(1),$(call $(MAL_IMPL)_STEP_TO_PROG,stepA),../$(2),") #"
59d10e1b 90ocaml_RUNSTEP = ../$(2) $(3)
9a54ea18 91matlab_RUNSTEP = matlab -nodisplay -nosplash -nodesktop -nojvm -r "run('../$(2)');quit;"
b8ee29b2 92perl_RUNSTEP = perl ../$(2) --raw $(3)
db4c329a 93php_RUNSTEP = php ../$(2) $(3)
01c97316 94ps_RUNSTEP = $(4)gs -q -I./ -dNODISPLAY -- ../$(2) $(3)$(4)
db4c329a 95python_RUNSTEP = $(PYTHON) ../$(2) $(3)
4d1456b9 96r_RUNSTEP = Rscript ../$(2) $(3)
f5223195 97racket_RUNSTEP = ../$(2) $(3)
db4c329a 98ruby_RUNSTEP = ruby ../$(2) $(3)
abdd56eb 99rust_RUNSTEP = ../$(2) $(3)
821930db 100scala_RUNSTEP = sbt 'run-main $($(1))$(if $(3), $(3),)'
ee7cd585 101vb_RUNSTEP = mono ../$(2) --raw $(3)
db4c329a
JM
102
103# Extra options to pass to runtest.py
104cs_TEST_OPTS = --redirect
aaba2493 105mal_TEST_OPTS = --redirect --start-timeout 60 --test-timeout 120
ee7cd585 106vb_TEST_OPTS = --redirect
31690700
JM
107
108
109# Derived lists
110STEPS = $(sort $(filter step%,$(.VARIABLES)))
111IMPL_TESTS = $(foreach impl,$(IMPLS),test^$(impl))
112STEP_TESTS = $(foreach step,$(STEPS),test^$(step))
113ALL_TESTS = $(filter-out $(EXCLUDE_TESTS),\
114 $(strip $(sort \
115 $(foreach impl,$(IMPLS),\
116 $(foreach step,$(STEPS),test^$(impl)^$(step))))))
117
118IMPL_STATS = $(foreach impl,$(IMPLS),stats^$(impl))
712af9ef 119IMPL_STATS_LISP = $(foreach impl,$(IMPLS),stats-lisp^$(impl))
31690700 120
db4c329a
JM
121IMPL_PERF = $(filter-out $(EXCLUDE_PERFS),$(foreach impl,$(IMPLS),perf^$(impl)))
122
31690700
JM
123#
124# Build rules
125#
126
127# Build a program in 'c' directory
128c/%:
129 $(MAKE) -C $(dir $(@)) $(notdir $(@))
130
131# Allow test, test^STEP, test^IMPL, and test^IMPL^STEP
132.SECONDEXPANSION:
133$(IMPL_TESTS): $$(filter $$@^%,$$(ALL_TESTS))
134
135.SECONDEXPANSION:
136$(STEP_TESTS): $$(foreach step,$$(subst test^,,$$@),$$(filter %^$$(step),$$(ALL_TESTS)))
137
138.SECONDEXPANSION:
139$(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@))))
140 @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
141 $(foreach step,$(word 3,$(subst ^, ,$(@))),\
142 cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \
143 $(foreach test,$(call STEP_TEST_FILES,$(impl),$(step)),\
144 echo '----------------------------------------------'; \
145 echo 'Testing $@, step file: $+, test file: $(test)'; \
db4c329a
JM
146 echo 'Running: ../runtest.py $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+))'; \
147 ../runtest.py $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+)))))
31690700
JM
148
149test: $(ALL_TESTS)
150tests: $(ALL_TESTS)
151
152
153# Stats rules
154
db4c329a
JM
155stats: $(IMPL_STATS)
156stats-lisp: $(IMPL_STATS_LISP)
157
31690700
JM
158.SECONDEXPANSION:
159$(IMPL_STATS):
160 @echo "----------------------------------------------"; \
161 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
162 echo "Stats for $(impl):"; \
163 $(MAKE) --no-print-directory -C $(impl) stats)
164
712af9ef
JM
165.SECONDEXPANSION:
166$(IMPL_STATS_LISP):
167 @echo "----------------------------------------------"; \
168 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
169 echo "Stats (lisp only) for $(impl):"; \
170 $(MAKE) --no-print-directory -C $(impl) stats-lisp)
171
db4c329a
JM
172
173# Performance test rules
174
175perf: $(IMPL_PERF)
176
177.SECONDEXPANSION:
178$(IMPL_PERF):
179 @echo "----------------------------------------------"; \
180 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
181 cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \
182 echo "Performance test for $(impl):"; \
183 echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal)'; \
184 $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal); \
185 echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal)'; \
186 $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal))
187