aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2015-01-23 16:55:06 -0500
committerChouser <chouser@n01se.net>2015-01-30 12:54:42 -0500
commit79ba3d608878cf99d4a61960ae0a29e2e4a96745 (patch)
tree128d00497194000ddfd19dfc0ece724ab04c4d7d
parent67736cf90b4f977b4b3ca3801e079040fc9fc0c9 (diff)
downloadmal-79ba3d608878cf99d4a61960ae0a29e2e4a96745.tar.gz
mal-79ba3d608878cf99d4a61960ae0a29e2e4a96745.zip
Ocaml: Finally fix race conditions in compilation
Also, use native compilation for everything except Ocaml REPL.
-rw-r--r--.gitignore3
-rw-r--r--ocaml/Makefile22
2 files changed, 18 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index 49aa62f..07d7921 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,9 @@ java/dependency-reduced-pom.xml
ocaml/*.cmi
ocaml/*.cmo
ocaml/*.swp
+ocaml/*.cmx
+ocaml/*.o
+ocaml/mal_lib.*
rust/target/
rust/mal
rust/Cargo.lock
diff --git a/ocaml/Makefile b/ocaml/Makefile
index f7df3a7..5e8b62a 100644
--- a/ocaml/Makefile
+++ b/ocaml/Makefile
@@ -1,21 +1,29 @@
STEPS = step0_repl.ml step1_read_print.ml step2_eval.ml step3_env.ml
MODULES = types.ml reader.ml printer.ml env.ml
-LIBS = str.cma
+LIBS = str.cmxa
+MAL_LIB = mal_lib.cmxa
STEP_BINS = $(STEPS:%.ml=%)
LAST_STEP_BIN = $(word $(words $(STEP_BINS)),$(STEP_BINS))
-MODULE_BINS = $(MODULES:%.ml=%.cmo)
all: $(STEP_BINS) mal
mal: $(LAST_STEP_BIN)
cp $< $@
-repl: $(MODULES)
- rlwrap ocaml $(LIBS) $(MODULE_BINS)
+# 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)
-$(STEP_BINS): %: %.ml $(MODULES)
- ocamlc $(LIBS) $(MODULES) $< -o $@
+$(MAL_LIB): $(MODULES)
+ ocamlopt -a $(MODULES) -o $@
+
+$(STEP_BINS): %: %.ml $(MAL_LIB)
+ ocamlopt $(LIBS) $(MAL_LIB) $< -o $@
clean:
- rm -f $(STEP_BINS) mal *.cmi *.cmo
+ rm -f $(STEP_BINS) mal mal_lib.* *.cmo *.cmx *.cmi *.o
+
+.PHONY: all repl clean