Fix metadata on functions.
[jackhill/mal.git] / Makefile
CommitLineData
31690700
JM
1#
2# Command line settings
3#
4
5MAL_IMPL = js
6
7#
8# Settings
9#
10
53beaa0a 11IMPLS = bash c clojure cs java js make php python ps mal
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
40php_STEP_TO_PROG = php/$($(1)).php
41python_STEP_TO_PROG = python/$($(1)).py
1b4a9012 42ps_STEP_TO_PROG = ps/$($(1)).ps
31690700
JM
43mal_STEP_TO_PROG = mal/$($(1)).mal
44
45
46bash_RUNTEST = ../runtest.py $(4) ../$(1) -- bash ../$(2) $(5)
47c_RUNTEST = ../runtest.py $(4) ../$(1) -- ../$(2) $(5)
48clojure_RUNTEST = ../runtest.py $(4) ../$(1) -- lein with-profile +$(3) trampoline run $(5)
53beaa0a
JM
49cs_RUNTEST = ../runtest.py --redirect $(4) ../$(1) -- mono --debug ../$(2) --raw $(5)
50#cs_RUNTEST = ../runtest.py --redirect $(4) ../$(1) -- mono --debug ../$(2) $(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)
54php_RUNTEST = ../runtest.py $(4) ../$(1) -- php ../$(2) $(5)
55python_RUNTEST = ../runtest.py $(4) ../$(1) -- python ../$(2) $(5)
1b4a9012 56ps_RUNTEST = ../runtest.py $(4) ../$(1) -- gs -q -dNODISPLAY ../$(2) $(5)
31690700
JM
57mal_RUNTEST = $(call $(MAL_IMPL)_RUNTEST,$(1),$(call $(MAL_IMPL)_STEP_TO_PROG,stepA),stepA,--start-timeout 30 --test-timeout 120,../$(2))
58
59
60# Derived lists
61STEPS = $(sort $(filter step%,$(.VARIABLES)))
62IMPL_TESTS = $(foreach impl,$(IMPLS),test^$(impl))
63STEP_TESTS = $(foreach step,$(STEPS),test^$(step))
64ALL_TESTS = $(filter-out $(EXCLUDE_TESTS),\
65 $(strip $(sort \
66 $(foreach impl,$(IMPLS),\
67 $(foreach step,$(STEPS),test^$(impl)^$(step))))))
68
69IMPL_STATS = $(foreach impl,$(IMPLS),stats^$(impl))
70
71#
72# Build rules
73#
74
75# Build a program in 'c' directory
76c/%:
77 $(MAKE) -C $(dir $(@)) $(notdir $(@))
78
79# Allow test, test^STEP, test^IMPL, and test^IMPL^STEP
80.SECONDEXPANSION:
81$(IMPL_TESTS): $$(filter $$@^%,$$(ALL_TESTS))
82
83.SECONDEXPANSION:
84$(STEP_TESTS): $$(foreach step,$$(subst test^,,$$@),$$(filter %^$$(step),$$(ALL_TESTS)))
85
86.SECONDEXPANSION:
87$(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@))))
88 @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
89 $(foreach step,$(word 3,$(subst ^, ,$(@))),\
90 cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \
91 $(foreach test,$(call STEP_TEST_FILES,$(impl),$(step)),\
92 echo '----------------------------------------------'; \
93 echo 'Testing $@, step file: $+, test file: $(test)'; \
94 echo 'Running: $(call $(impl)_RUNTEST,$(test),$(+),$(step))'; \
95 $(call $(impl)_RUNTEST,$(test),$(+),$(step)))))
96
97test: $(ALL_TESTS)
98tests: $(ALL_TESTS)
99
100
101# Stats rules
102
103.SECONDEXPANSION:
104$(IMPL_STATS):
105 @echo "----------------------------------------------"; \
106 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
107 echo "Stats for $(impl):"; \
108 $(MAKE) --no-print-directory -C $(impl) stats)
109
110stats: $(IMPL_STATS)