README: typo.
[jackhill/mal.git] / Makefile
CommitLineData
31690700
JM
1#
2# Command line settings
3#
4
5MAL_IMPL = js
6
7#
8# Settings
9#
10
f705f0fc 11IMPLS = bash c clojure cs java js make mal php ps python ruby
31690700
JM
12
13step0 = step0_repl
14step1 = step1_read_print
15step2 = step2_eval
16step3 = step3_env
17step4 = step4_if_fn_do
18step5 = step5_tco
19step6 = step6_file
20step7 = step7_quote
21step8 = step8_macros
22step9 = step9_interop
23stepA = stepA_more
24
17ae845e 25EXCLUDE_TESTS = test^make^step5 test^mal^step0 test^mal^step5 test^mal^step9 test^java^step9 test^cs^step9
31690700
JM
26
27#
28# Utility functions
29#
30
31STEP_TEST_FILES = $(strip $(wildcard $(1)/tests/$($(2)).mal) $(wildcard tests/$($(2)).mal))
32
33bash_STEP_TO_PROG = bash/$($(1)).sh
34c_STEP_TO_PROG = c/$($(1))
35clojure_STEP_TO_PROG = clojure/src/$($(1)).clj
53beaa0a 36cs_STEP_TO_PROG = cs/$($(1)).exe
31690700
JM
37java_STEP_TO_PROG = java/src/main/java/mal/$($(1)).java
38js_STEP_TO_PROG = js/$($(1)).js
39make_STEP_TO_PROG = make/$($(1)).mk
f705f0fc 40mal_STEP_TO_PROG = mal/$($(1)).mal
31690700 41php_STEP_TO_PROG = php/$($(1)).php
1b4a9012 42ps_STEP_TO_PROG = ps/$($(1)).ps
f705f0fc
JM
43python_STEP_TO_PROG = python/$($(1)).py
44ruby_STEP_TO_PROG = ruby/$($(1)).rb
31690700
JM
45
46
47bash_RUNTEST = ../runtest.py $(4) ../$(1) -- bash ../$(2) $(5)
48c_RUNTEST = ../runtest.py $(4) ../$(1) -- ../$(2) $(5)
49clojure_RUNTEST = ../runtest.py $(4) ../$(1) -- lein with-profile +$(3) trampoline run $(5)
53beaa0a 50cs_RUNTEST = ../runtest.py --redirect $(4) ../$(1) -- mono --debug ../$(2) --raw $(5)
31690700
JM
51java_RUNTEST = ../runtest.py $(4) ../$(1) -- mvn -quiet exec:java -Dexec.mainClass="mal.$($(3))" -Dexec.args="--raw$(if $(5), $(5),)"
52js_RUNTEST = ../runtest.py $(4) ../$(1) -- node ../$(2) $(5)
53make_RUNTEST = ../runtest.py $(4) ../$(1) -- make -f ../$(2) $(5)
f705f0fc 54mal_RUNTEST = $(call $(MAL_IMPL)_RUNTEST,$(1),$(call $(MAL_IMPL)_STEP_TO_PROG,stepA),stepA,--start-timeout 30 --test-timeout 120,../$(2))
31690700 55php_RUNTEST = ../runtest.py $(4) ../$(1) -- php ../$(2) $(5)
166398b8 56ps_RUNTEST = ../runtest.py $(4) ../$(1) -- "gs -q -dNODISPLAY -- ../$(2) $(5)"
f705f0fc
JM
57python_RUNTEST = ../runtest.py $(4) ../$(1) -- python ../$(2) $(5)
58ruby_RUNTEST = ../runtest.py $(4) ../$(1) -- ruby ../$(2) $(5)
31690700
JM
59
60
61# Derived lists
62STEPS = $(sort $(filter step%,$(.VARIABLES)))
63IMPL_TESTS = $(foreach impl,$(IMPLS),test^$(impl))
64STEP_TESTS = $(foreach step,$(STEPS),test^$(step))
65ALL_TESTS = $(filter-out $(EXCLUDE_TESTS),\
66 $(strip $(sort \
67 $(foreach impl,$(IMPLS),\
68 $(foreach step,$(STEPS),test^$(impl)^$(step))))))
69
70IMPL_STATS = $(foreach impl,$(IMPLS),stats^$(impl))
712af9ef 71IMPL_STATS_LISP = $(foreach impl,$(IMPLS),stats-lisp^$(impl))
31690700
JM
72
73#
74# Build rules
75#
76
77# Build a program in 'c' directory
78c/%:
79 $(MAKE) -C $(dir $(@)) $(notdir $(@))
80
81# Allow test, test^STEP, test^IMPL, and test^IMPL^STEP
82.SECONDEXPANSION:
83$(IMPL_TESTS): $$(filter $$@^%,$$(ALL_TESTS))
84
85.SECONDEXPANSION:
86$(STEP_TESTS): $$(foreach step,$$(subst test^,,$$@),$$(filter %^$$(step),$$(ALL_TESTS)))
87
88.SECONDEXPANSION:
89$(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@))))
90 @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
91 $(foreach step,$(word 3,$(subst ^, ,$(@))),\
92 cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \
93 $(foreach test,$(call STEP_TEST_FILES,$(impl),$(step)),\
94 echo '----------------------------------------------'; \
95 echo 'Testing $@, step file: $+, test file: $(test)'; \
96 echo 'Running: $(call $(impl)_RUNTEST,$(test),$(+),$(step))'; \
97 $(call $(impl)_RUNTEST,$(test),$(+),$(step)))))
98
99test: $(ALL_TESTS)
100tests: $(ALL_TESTS)
101
102
103# Stats rules
104
105.SECONDEXPANSION:
106$(IMPL_STATS):
107 @echo "----------------------------------------------"; \
108 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
109 echo "Stats for $(impl):"; \
110 $(MAKE) --no-print-directory -C $(impl) stats)
111
712af9ef
JM
112.SECONDEXPANSION:
113$(IMPL_STATS_LISP):
114 @echo "----------------------------------------------"; \
115 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
116 echo "Stats (lisp only) for $(impl):"; \
117 $(MAKE) --no-print-directory -C $(impl) stats-lisp)
118
31690700 119stats: $(IMPL_STATS)
712af9ef 120stats-lisp: $(IMPL_STATS_LISP)