2 # Command line settings
13 IMPLS
= bash c clojure cs java js make mal perl php ps python ruby
16 step1
= step1_read_print
19 step4
= step4_if_fn_do
27 EXCLUDE_TESTS
= test^make^step5
test^mal^step0
test^mal^step5
test^mal^step9
test^java^step9
test^cs^step9
28 EXCLUDE_PERFS
= perf^mal
# TODO: fix this
34 STEP_TEST_FILES
= $(strip $(wildcard $(1)/tests
/$($(2)).mal
) $(wildcard tests
/$($(2)).mal
))
36 bash_STEP_TO_PROG
= bash
/$($(1)).sh
37 c_STEP_TO_PROG
= c
/$($(1))
38 clojure_STEP_TO_PROG
= clojure
/src
/$($(1)).clj
39 cs_STEP_TO_PROG
= cs
/$($(1)).exe
40 java_STEP_TO_PROG
= java
/src
/main
/java
/mal
/$($(1)).java
41 js_STEP_TO_PROG
= js
/$($(1)).js
42 make_STEP_TO_PROG
= make
/$($(1)).mk
43 mal_STEP_TO_PROG
= mal
/$($(1)).mal
44 perl_STEP_TO_PROG
= perl
/$($(1)).pl
45 php_STEP_TO_PROG
= php
/$($(1)).php
46 ps_STEP_TO_PROG
= ps
/$($(1)).ps
47 python_STEP_TO_PROG
= python
/$($(1)).py
48 ruby_STEP_TO_PROG
= ruby
/$($(1)).rb
51 bash_RUNSTEP
= bash ..
/$(2) $(3)
52 c_RUNSTEP
= ..
/$(2) $(3)
53 clojure_RUNSTEP
= lein with-profile
+$(1) trampoline run
$(3)
54 cs_RUNSTEP
= mono ..
/$(2) --raw
$(3)
55 java_RUNSTEP
= mvn
-quiet exec
:java
-Dexec.mainClass
="mal.$($(1))" -Dexec.args
="--raw$(if $(3), $(3),)"
56 js_RUNSTEP
= node ..
/$(2) $(3)
57 make_RUNSTEP
= make
-f ..
/$(2) $(3)
58 mal_RUNSTEP
= $(call
$(MAL_IMPL
)_RUNSTEP
,$(1),$(call
$(MAL_IMPL
)_STEP_TO_PROG
,stepA
),..
/$(2),") #"
59 perl_RUNSTEP
= perl ..
/$(2) $(3)
60 php_RUNSTEP
= php ..
/$(2) $(3)
61 ps_RUNSTEP
= $(4)gs
-q
-dNODISPLAY
-- ..
/$(2) $(3)$(4)
62 python_RUNSTEP
= $(PYTHON
) ..
/$(2) $(3)
63 ruby_RUNSTEP
= ruby ..
/$(2) $(3)
65 # Extra options to pass to runtest.py
66 cs_TEST_OPTS
= --redirect
67 mal_TEST_OPTS
= --start-timeout
60 --test-timeout
120
71 STEPS
= $(sort $(filter step
%,$(.VARIABLES
)))
72 IMPL_TESTS
= $(foreach impl
,$(IMPLS
),test^
$(impl
))
73 STEP_TESTS
= $(foreach step
,$(STEPS
),test^
$(step
))
74 ALL_TESTS
= $(filter-out $(EXCLUDE_TESTS
),\
76 $(foreach impl
,$(IMPLS
),\
77 $(foreach step
,$(STEPS
),test^
$(impl
)^
$(step
))))))
79 IMPL_STATS
= $(foreach impl
,$(IMPLS
),stats^
$(impl
))
80 IMPL_STATS_LISP
= $(foreach impl
,$(IMPLS
),stats-lisp^
$(impl
))
82 IMPL_PERF
= $(filter-out $(EXCLUDE_PERFS
),$(foreach impl
,$(IMPLS
),perf^
$(impl
)))
88 # Build a program in 'c' directory
90 $(MAKE
) -C
$(dir $(@
)) $(notdir $(@
))
92 # Allow test, test^STEP, test^IMPL, and test^IMPL^STEP
94 $(IMPL_TESTS
): $$(filter $$@^
%,$$(ALL_TESTS
))
97 $(STEP_TESTS
): $$(foreach step
,$$(subst test^
,,$$@
),$$(filter %^
$$(step
),$$(ALL_TESTS
)))
100 $(ALL_TESTS
): $$(call
$$(word 2,$$(subst ^
, ,$$(@
)))_STEP_TO_PROG
,$$(word 3,$$(subst ^
, ,$$(@
))))
101 @
$(foreach impl
,$(word 2,$(subst ^
, ,$(@
))),\
102 $(foreach step
,$(word 3,$(subst ^
, ,$(@
))),\
103 cd
$(if
$(filter mal
,$(impl
)),$(MAL_IMPL
),$(impl
)); \
104 $(foreach test,$(call STEP_TEST_FILES
,$(impl
),$(step
)),\
105 echo
'----------------------------------------------'; \
106 echo
'Testing $@, step file: $+, test file: $(test)'; \
107 echo
'Running: ../runtest.py $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+))'; \
108 ..
/runtest.py
$(call
$(impl
)_TEST_OPTS
) ..
/$(test) -- $(call
$(impl
)_RUNSTEP
,$(step
),$(+)))))
117 stats-lisp
: $(IMPL_STATS_LISP
)
121 @echo
"----------------------------------------------"; \
122 $(foreach impl
,$(word 2,$(subst ^
, ,$(@
))),\
123 echo
"Stats for $(impl):"; \
124 $(MAKE
) --no-print-directory
-C
$(impl
) stats
)
128 @echo
"----------------------------------------------"; \
129 $(foreach impl
,$(word 2,$(subst ^
, ,$(@
))),\
130 echo
"Stats (lisp only) for $(impl):"; \
131 $(MAKE
) --no-print-directory
-C
$(impl
) stats-lisp
)
134 # Performance test rules
140 @echo
"----------------------------------------------"; \
141 $(foreach impl
,$(word 2,$(subst ^
, ,$(@
))),\
142 cd
$(if
$(filter mal
,$(impl
)),$(MAL_IMPL
),$(impl
)); \
143 echo
"Performance test for $(impl):"; \
144 echo
'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal)'; \
145 $(call
$(impl
)_RUNSTEP
,stepA
,$(call
$(impl
)_STEP_TO_PROG
,stepA
),..
/tests
/perf1.mal
); \
146 echo
'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal)'; \
147 $(call
$(impl
)_RUNSTEP
,stepA
,$(call
$(impl
)_STEP_TO_PROG
,stepA
),..
/tests
/perf2.mal
))