From 686049b77691f8fc4753af0a77377041d2c8978a Mon Sep 17 00:00:00 2001 From: Christian Lindig Date: Mon, 21 Sep 2015 20:41:54 +0200 Subject: [PATCH 1/2] Now using ocamlbuild for building. Rewrote Makefile, introduces _tags. .gitignore is simplified since now almost all build files reside in _build. Using "git archive" to build a zip file in target "zip". --- ml-proto/src/.gitignore | 11 +---- ml-proto/src/Makefile | 99 +++++++++++++---------------------------- ml-proto/src/_tags | 2 + 3 files changed, 33 insertions(+), 79 deletions(-) create mode 100644 ml-proto/src/_tags diff --git a/ml-proto/src/.gitignore b/ml-proto/src/.gitignore index 929926e499..4cd5717649 100644 --- a/ml-proto/src/.gitignore +++ b/ml-proto/src/.gitignore @@ -1,16 +1,7 @@ -lexer.ml -parser.ml -parser.mli -*.cmi -*.cmo -*.cmx -*.exe -*.o -*.output -*.depend *.native *.byte *.opt *.zip _build wasm +unopt diff --git a/ml-proto/src/Makefile b/ml-proto/src/Makefile index a08bad649f..4c18fb0b2d 100644 --- a/ml-proto/src/Makefile +++ b/ml-proto/src/Makefile @@ -1,83 +1,44 @@ # -# (c) 2015 Andreas Rossberg +# This Makfile assumes we can use ocamlfind to locate libraries. This +# is the case in a typical OCaml environment that uses Opam. Use +# +# make check +# +# to see that relevant libraries can be found. # -NAME = wasm -INCLUDES = -I host -I given -I spec -MODULES = \ - host/params host/flags given/lib given/source given/float32 given/float64 spec/error \ - spec/types spec/values spec/memory spec/ast \ - spec/check spec/arithmetic spec/eval \ - host/print host/builtins host/script \ - host/lexer host/parser \ - host/main -NOMLI = host/params host/flags spec/types spec/values spec/ast host/main -PARSERS = host/parser -LEXERS = host/lexer -LIBRARIES = bigarray nums str -SAMPLES = -TEXTS = - -MLS = $(MODULES:%=%.ml) -MLIS = $(filter-out $(NOMLI:%=%.mli), $(MODULES:%=%.mli)) -MLYS = $(PARSERS:%=%.mly) -MLLS = $(LEXERS:%=%.mll) -CMOS = $(MODULES:%=%.cmo) -CMXS = $(MODULES:%=%.cmx) -CMAS = $(LIBRARIES:%=%.cma) -CMXAS = $(LIBRARIES:%=%.cmxa) -TXTS = $(TEXTS:%=%.txt) - -OCAMLCOPTS = # -w +a-4-41-42-44-45 +NAME = wasm +Makefile = Makefile -$(NAME): $(CMXS) Makefile - ocamlopt $(CMXAS) $(CMXS) $(OCAMLCOPTS) -o $@ +OCB_FLAGS += -use-ocamlfind +OCB_FLAGS += # -cflags -w +OCB_FLAGS += # -cflags +a-4-41-42-44-45 +OCB_FLAGS += -I host -I given -I spec +OCB = ocamlbuild $(OCB_FLAGS) -unopt: $(CMOS) Makefile - ocamlc $(CMAS) $(CMOS) $(OCAMLCOPTS) -g -o $(NAME) +all: $(NAME) unopt -$(filter-out $(NOMLI:%=%.cmo), $(CMOS)): %.cmo: %.cmi -$(filter-out $(NOMLI:%=%.cmx), $(CMXS)): %.cmx: %.cmi +$(NAME): main.native + mv $< $@ -Makefile.depend: $(MLS) $(MLIS) Makefile - ocamldep $(INCLUDES) $^ >$@ +unopt: main.byte + mv $< $@ --include Makefile.depend +main.native: $(MAKEFILE) check + $(OCB) $@ -zip: $(MLS) $(MLIS) $(MLYS) $(MLLS) Makefile $(IMLS) $(TXTS) - mkdir tmp tmp/$(NAME) - cp $^ tmp/$(NAME) - rm -f $(NAME).zip - (cd tmp; zip -r ../$(NAME).zip $(NAME)) - rm -r tmp +main.byte: $(MAKEFILE) check + $(OCB) $@ clean: - rm -f given/*.cmi given/*.cmo given/*.cmx given/*.o - rm -f spec/*.cmi spec/*.cmo spec/*.cmx spec/*.o - rm -f host/*.cmi host/*.cmo host/*.cmx host/*.o host/*.output - rm -f *.depend *.native *.byte $(NAME) $(NAME).opt $(NAME).zip - rm -rf _build - rm -f *~ - -distclean: clean - rm -f $(PARSERS:%=%.mli) $(PARSERS:%=%.ml) $(LEXERS:%=%.ml) - -%.cmi: %.mli - ocamlc -c $(INCLUDES) $(OCAMLCOPTS) $< - -%.cmo: %.ml - ocamlc -c $(INCLUDES) $(OCAMLCOPTS) -g $< - -%.cmx: %.ml - ocamlopt -c $(INCLUDES) $(OCAMLCOPTS) $< - -%.ml: %.mly - ocamlyacc -v $< + $(OCB) -clean -%.mli: %.mly - ocamlyacc -v $< +check: + # check that we can find all relevant libraries + ocamlfind query str num bigarray -%.ml: %.mll - ocamllex $< +zip: + git archive --format=zip --prefix=$(NAME)/ \ + -o $(NAME).zip HEAD -.PRECIOUS: %.ml %.mli +.PHONY: all clean check zip diff --git a/ml-proto/src/_tags b/ml-proto/src/_tags new file mode 100644 index 0000000000..7412acab8e --- /dev/null +++ b/ml-proto/src/_tags @@ -0,0 +1,2 @@ +true: bin_annot +true: package(bigarray), package(num), package(str) From 0bbf46afbba866b6ced634950754a1d5b1497e8f Mon Sep 17 00:00:00 2001 From: Christian Lindig Date: Tue, 22 Sep 2015 18:08:48 +0200 Subject: [PATCH 2/2] No longer rely on ocamlfind; should work with plain OCaml distribution. --- ml-proto/src/Makefile | 17 ++++++++--------- ml-proto/src/_tags | 1 - 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ml-proto/src/Makefile b/ml-proto/src/Makefile index 4c18fb0b2d..a2ec1a78d8 100644 --- a/ml-proto/src/Makefile +++ b/ml-proto/src/Makefile @@ -1,18 +1,16 @@ +# vim: sw=8 ts=8 noet: # -# This Makfile assumes we can use ocamlfind to locate libraries. This -# is the case in a typical OCaml environment that uses Opam. Use -# -# make check -# -# to see that relevant libraries can be found. +# This Makefile uses ocamlbuild but does not rely on ocamlfind +# or the Opam package manager. # NAME = wasm Makefile = Makefile -OCB_FLAGS += -use-ocamlfind +OCB_FLAGS += # -use-ocamlfind OCB_FLAGS += # -cflags -w OCB_FLAGS += # -cflags +a-4-41-42-44-45 +OCB_FLAGS += -libs nums,str,bigarray OCB_FLAGS += -I host -I given -I spec OCB = ocamlbuild $(OCB_FLAGS) @@ -24,10 +22,10 @@ $(NAME): main.native unopt: main.byte mv $< $@ -main.native: $(MAKEFILE) check +main.native: $(MAKEFILE) $(OCB) $@ -main.byte: $(MAKEFILE) check +main.byte: $(MAKEFILE) $(OCB) $@ clean: @@ -35,6 +33,7 @@ clean: check: # check that we can find all relevant libraries + # when using ocamlfind ocamlfind query str num bigarray zip: diff --git a/ml-proto/src/_tags b/ml-proto/src/_tags index 7412acab8e..889f1638c7 100644 --- a/ml-proto/src/_tags +++ b/ml-proto/src/_tags @@ -1,2 +1 @@ true: bin_annot -true: package(bigarray), package(num), package(str)