aboutsummaryrefslogtreecommitdiff
path: root/ocaml/Makefile
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2015-01-30 12:06:45 -0600
committerJoel Martin <github@martintribe.org>2015-01-30 12:06:45 -0600
commit644e5ff95e186094054221cf2f13048630f81fa0 (patch)
tree14f965eee633f4ea185f640c6130e54063056d6b /ocaml/Makefile
parentbf518367d0706b2fa727acc5326230ef8d3c812b (diff)
parentbc6448bce925d18ecb893e8e8ee10d2b2178b31a (diff)
downloadmal-644e5ff95e186094054221cf2f13048630f81fa0.tar.gz
mal-644e5ff95e186094054221cf2f13048630f81fa0.zip
Merge pull request #3 from Chouser/ocaml
Ocaml
Diffstat (limited to 'ocaml/Makefile')
-rw-r--r--ocaml/Makefile31
1 files changed, 31 insertions, 0 deletions
diff --git a/ocaml/Makefile b/ocaml/Makefile
new file mode 100644
index 0000000..72d159a
--- /dev/null
+++ b/ocaml/Makefile
@@ -0,0 +1,31 @@
+STEPS = step0_repl.ml step1_read_print.ml step2_eval.ml step3_env.ml \
+ step4_if_fn_do.ml step5_tco.ml step6_file.ml step7_quote.ml \
+ step8_macros.ml step9_try.ml stepA_interop.ml
+MODULES = types.ml reader.ml printer.ml env.ml core.ml
+LIBS = str.cmxa unix.cmxa
+MAL_LIB = mal_lib.cmxa
+
+STEP_BINS = $(STEPS:%.ml=%)
+LAST_STEP_BIN = $(word $(words $(STEP_BINS)),$(STEP_BINS))
+
+all: $(STEP_BINS) mal
+
+mal: $(LAST_STEP_BIN)
+ cp $< $@
+
+# ocaml repl apparently needs bytecode, not native, compilation.
+# Just do it all right here:
+repl:
+ ocamlc -c $(LIBS:%.cmxa=%.cma) $(MODULES) $(STEPS)
+ rlwrap ocaml $(LIBS:%.cmxa=%.cma) $(MODULES:%.ml=%.cmo)
+
+$(MAL_LIB): $(MODULES)
+ ocamlopt -a $(MODULES) -o $@
+
+$(STEP_BINS): %: %.ml $(MAL_LIB)
+ ocamlopt $(LIBS) $(MAL_LIB) $< -o $@
+
+clean:
+ rm -f $(STEP_BINS) mal mal_lib.* *.cmo *.cmx *.cmi *.o
+
+.PHONY: all repl clean