-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
177 lines (144 loc) · 6.45 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
.PHONY: all clean test graph doc index release report coverage count doc doc-export install uninstall web/js/mezzo.js
# If the file doesn't exist, there's a rule for generating it.
-include Makefile.config
# We used to have Makefile.local but now there's a configure script that should
# auto-detect utilities properly and put the appropriate values in
# Makefile.config. If something's missing, the configure script should be fixed!
# We have either the code of the type-checker, or the code of the run-time
# support library.
ML_DIRS := lib parsing typing utils interpreter compiler tests/unit ocamlbuild
MZ_DIRS := mezzolib corelib stdlib
# Allow an override for Menhir.
ifndef MENHIR
MENHIR := menhir
endif
# Our tools are ocamlbuild and ocamlfind
OCAMLBUILD := ocamlbuild -j 4 -use-ocamlfind -use-menhir \
-menhir "$(MENHIR) --explain --infer -la 1 --table" \
-classic-display \
$(addprefix -I ,$(ML_DIRS)) \
$(addprefix -I ,$(MZ_DIRS))
OCAMLFIND := ocamlfind
# We're building two programs: the mezzo compiler and the test suite.
MAIN := mezzo
TESTSUITE := testsuite
# We're also building libraries for the run-time support of Mezzo prorams.
LIBS := mezzolib/MezzoLib.cma mezzolib/MezzoLib.cmxa \
corelib/MezzoCoreLib.cma corelib/MezzoCoreLib.cmxa \
stdlib/MezzoStdLib.cma stdlib/MezzoStdLib.cmxa \
ocamlbuild/ocamlbuild_mezzo.cma ocamlbuild/ocamlbuild_mezzo.cmxa
# These are our targets.
TARGETS := $(MAIN).native $(TESTSUITE).native $(LIBS)
all: configure.ml parsing/Keywords.ml vim/syntax/mezzo.vim myocamlbuild.ml
# This re-generates the list of modules that go into MezzoStdLib
$(MAKE) -C stdlib/
# This is the big call that builds everything.
$(OCAMLBUILD) $(TARGETS)
# For convenience, two symbolic links.
ln -sf $(MAIN).native $(MAIN)
ln -sf $(TESTSUITE).native $(TESTSUITE)
configure.ml Makefile.config: configure
# If the user hasn't run ./configure already, we're assuming a local
# setup where Mezzo isn't meant to be installed.
./configure --local
parsing/Keywords.ml: parsing/Keywords parsing/KeywordGenerator.ml
ocaml parsing/KeywordGenerator.ml < $< > $@
if [ -d ../misc/pygments/mezzolexer ] ; then \
ocaml parsing/KeywordPygments.ml < $< > ../misc/pygments/mezzolexer/mezzokeywords.py ; \
fi
vim/syntax/mezzo.vim: parsing/Keywords parsing/KeywordGenerator.ml
ocaml parsing/KeywordGenerator.ml -vim [email protected] < $< > $@
web/js/mezzo.js:
$(OCAMLBUILD) \
-tag-line "not (<corelib/*> or <stdlib/*> or <parsing/grammar.*>): package(js_of_ocaml), package(js_of_ocaml.syntax), syntax(camlp4o)" \
mezzoweb.byte
js_of_ocaml mezzoweb.byte -o $@ web/js/override.js \
-I ./ -I web \
-file corelib/autoload:/ -file corelib=mz,mzi:/ -file stdlib=mz,mzi:/ -file demos=mz,mzi:/
myocamlbuild.ml: ocamlbuild/ocamlbuild_mezzo.ml myocamlbuild.pre.ml
$(shell printf "(* This file is auto-generated by the Makefile *)\n" > $@)
$(shell printf "module Ocamlbuild_mezzo = struct\n" >> $@)
$(shell cat ocamlbuild/ocamlbuild_mezzo.ml >> $@)
$(shell printf "end;;\n" >> $@)
$(shell cat myocamlbuild.pre.ml >> $@)
@echo "myocamlbuild.ml generated"
clean:
rm -f *~ $(MAIN) $(MAIN).native $(TESTSUITE) $(TESTSUITE).native configure.ml Makefile.config \
myocamlbuild.ml parsing/Keywords.ml vim/syntax/mezzo.vim web/js/mezzo.js
$(OCAMLBUILD) -clean
test: all
OCAMLRUNPARAM=b $(TIME) --format="Elapsed time (wall-clock): %E" ./testsuite
install: all
$(OCAMLFIND) install mezzo META \
$(patsubst %,_build/%,$(LIBS)) \
$(shell $(FIND) _build/ocamlbuild/ \
-iname '*.a' -or -iname '*.cmi' -or -iname '*.cmx') \
$(shell $(FIND) _build/corelib/ \
-iname '*.a' -or -iname '*.cmi' -or -iname '*.cmx') \
$(shell $(FIND) _build/stdlib/ \
-iname '*.a' -or -iname '*.cmi' -or -iname '*.cmx') \
$(shell $(FIND) _build/mezzolib/ \
-iname '*.a' -or -iname '*.cmi' -or -iname '*.cmx') \
$(shell $(FIND) _build/corelib/ -iname '*.mzi' -or -iname '*.mz') \
$(shell $(FIND) _build/stdlib/ -iname '*.mzi' -or -iname '*.mz') \
corelib/autoload
uninstall:
$(OCAMLFIND) remove mezzo
################################################################################
### Less-important build rules, mostly for the ease of us developers.
BUILDDIRS = -I _build $(shell $(FIND) _build -maxdepth 1 -type d -printf "-I _build/%f ")
PACKAGES := -package menhirLib,ocamlbuild,yojson,ulex,pprint,fix
# Re-generate the TAGS file
tags: all
otags $(shell $(FIND) $(ML_DIRS) \( -iname '*.ml' -or -iname '*.mli' \) -and -not -iname 'Lexer.ml')
# When you need to build a small program linking with all the libraries (to
# write a test for a very specific function, for instance).
%.byte: FORCE
$(OCAMLBUILD) $(INCLUDE) $*.byte
# For easily debugging inside an editor. When editing tests/foo.mz, just do (in
# vim): ":make %".
#%.mz: mezzo.byte FORCE
# OCAMLRUNPARAM=b ./mezzo.byte -I tests -nofancypants $@ -debug 5 2>&1 | tail -n 80
%.mz: all
OCAMLRUNPARAM=b ./mezzo.native -I tests -nofancypants $@ 2>&1 | tail -n 200
FORCE:
# For printing the signature of an .ml file
%.mli: all
$(OCAMLFIND) ocamlc $(PACKAGES) -i $(BUILDDIRS) $*.ml
# The index of all the nifty visualizations we've built so far
index:
$(shell cd viewer && ./gen_index.sh)
# TAG=m1 make release ; this just exports the current src/ directory
release:
git archive --format tar --prefix mezzo-$(TAG)/ $(TAG) | bzip2 -9 > ../mezzo-$(TAG).tar.bz2
report:
bisect-report -I _build -html report coverage*.out
coverage:
BISECT_FILE=coverage ./testsuite
graph: all
-$(OCAMLFIND) ocamldoc -dot $(BUILDDIRS)\
$(PACKAGES)\
-o graph.dot\
$(shell $(FIND) typing/ -iname '*.ml' -or -iname '*.mli')\
configure.ml mezzo.ml
sed -i 's/rotate=90;//g' graph.dot
dot -Tsvg graph.dot > misc/graph.svg
sed -i 's/^<text\([^>]\+\)>\([^<]\+\)/<text\1><a xlink:href="\2.html" target="_parent">\2<\/a>/' misc/graph.svg
sed -i 's/Times Roman,serif/DejaVu Sans, Helvetica, sans/g' misc/graph.svg
rm -f graph.dot
doc: graph
-$(OCAMLFIND) ocamldoc $(PACKAGES) \
$(BUILDDIRS) \
-stars -html \
-d ../misc/doc \
-intro ../misc/doc/main \
-charset utf8 -css-style ocamlstyle.css\
configure.ml mezzo.ml\
$(shell $(FIND) _build -maxdepth 2 -iname '*.mli')
sed -i 's/<\/body>/<p align="center"><object type="image\/svg+xml" data="graph.svg"><\/object><\/p><\/body>/' ../misc/doc/index.html
cp -f misc/graph.svg ../misc/doc/graph.svg
doc-export:
rm -rf ~/public_html/mezzo-lang/doc/
cp -R ../misc/doc ~/public_html/mezzo-lang/
count:
sloccount parsing typing utils viewer lib mezzo.ml