Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now using ocamlbuild for building. Rewrote Makefile, introduces _tags. #83

Merged
merged 3 commits into from
Sep 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions ml-proto/src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
lexer.ml
parser.ml
parser.mli
*.cmi
*.cmo
*.cmx
*.exe
*.o
*.output
*.depend
*.native
*.byte
*.opt
*.zip
_build
wasm
unopt
98 changes: 29 additions & 69 deletions ml-proto/src/Makefile
Original file line number Diff line number Diff line change
@@ -1,83 +1,43 @@
# vim: sw=8 ts=8 noet:
#
# (c) 2015 Andreas Rossberg
# This Makefile uses ocamlbuild but does not rely on ocamlfind
# or the Opam package manager.
#

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 =
NAME = wasm
Makefile = Makefile

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)
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)

OCAMLCOPTS = # -w +a-4-41-42-44-45
all: $(NAME) unopt

$(NAME): $(CMXS) Makefile
ocamlopt $(CMXAS) $(CMXS) $(OCAMLCOPTS) -o $@
$(NAME): main.native
mv $< $@

unopt: $(CMOS) Makefile
ocamlc $(CMAS) $(CMOS) $(OCAMLCOPTS) -g -o $(NAME)
unopt: main.byte
mv $< $@

$(filter-out $(NOMLI:%=%.cmo), $(CMOS)): %.cmo: %.cmi
$(filter-out $(NOMLI:%=%.cmx), $(CMXS)): %.cmx: %.cmi
main.native: $(MAKEFILE)
$(OCB) $@

Makefile.depend: $(MLS) $(MLIS) Makefile
ocamldep $(INCLUDES) $^ >$@

-include Makefile.depend

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)
$(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
# when using ocamlfind
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
1 change: 1 addition & 0 deletions ml-proto/src/_tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true: bin_annot