-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
160 lines (115 loc) · 3.48 KB
/
Makefile
File metadata and controls
160 lines (115 loc) · 3.48 KB
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
# This Makefile uses ocamlbuild but does not rely on ocamlfind or the Opam
# package manager to build. However, Opam package management is available
# optionally through the check/install/uninstall targets.
#
# The $(JSLIB) target requires node.js and BuckleScript.
#
# See README.me for instructions.
# Configuration
NAME = wasm
UNOPT = $(NAME).debug
OPT = $(NAME)
LIB = $(NAME)
ZIP = $(NAME).zip
JSLIB = wast.js
WINMAKE = winmake.bat
DIRS = util syntax binary text valid runtime exec script host main
LIBS = bigarray
FLAGS = -cflags '-w +a-4-27-42-44-45 -warn-error +a-3'
OCB = ocamlbuild $(FLAGS) $(DIRS:%=-I %) $(LIBS:%=-libs %)
JS = # set to JS shell command to run JS tests
# Main targets
.PHONY: default opt unopt libopt libunopt jslib all land zip
default: opt
debug: unopt
opt: $(OPT)
unopt: $(UNOPT)
libopt: _build/$(LIB).cmx
libunopt: _build/$(LIB).cmo
jslib: $(JSLIB)
all: unopt opt libunopt libopt test
land: $(WINMAKE) all
zip: $(ZIP)
# Building executable
empty =
space = $(empty) $(empty)
comma = ,
.INTERMEDIATE: _tags
_tags:
echo >$@ "true: bin_annot"
echo >>$@ "true: debug"
echo >>$@ "<{$(subst $(space),$(comma),$(DIRS))}/*.cmx>: for-pack($(PACK))"
$(UNOPT): main.byte
mv $< $@
$(OPT): main.native
mv $< $@
.PHONY: main.byte main.native
main.byte: _tags
$(OCB) -quiet $@
main.native: _tags
$(OCB) -quiet $@
# Building library
PACK = $(shell echo `echo $(LIB) | sed 's/^\(.\).*$$/\\1/g' | tr [:lower:] [:upper:]``echo $(LIB) | sed 's/^.\(.*\)$$/\\1/g'`)
.INTERMEDIATE: $(LIB).mlpack
$(LIB).mlpack: $(DIRS)
ls $(DIRS:%=%/*.ml*) \
| sed 's:\(.*/\)\{0,1\}\(.*\)\.[^\.]*:\2:' \
| grep -v main \
| sort | uniq \
>$@
_build/$(LIB).cmo: $(LIB).mlpack _tags
$(OCB) -quiet $(LIB).cmo
_build/$(LIB).cmx: $(LIB).mlpack _tags
$(OCB) -quiet $(LIB).cmx
# Building JavaScript library
.PHONY: $(JSLIB)
$(JSLIB): $(UNOPT)
mkdir -p _build/jslib/src
cp meta/jslib/* _build/jslib
cp $(DIRS:%=_build/%/*.ml*) meta/jslib/*.ml _build/jslib/src
rm _build/jslib/src/*.ml[^i]
(cd _build/jslib; ./build.sh ../../$@)
# Building Windows build file
$(WINMAKE): clean
echo rem Auto-generated from Makefile! >$@
echo set NAME=$(NAME) >>$@
echo if \'%1\' neq \'\' set NAME=%1 >>$@
$(OCB) main.byte \
| grep -v ocamldep \
| grep -v mkdir \
| sed s:`which ocaml`:ocaml:g \
| sed s:main/main.d.byte:%NAME%.exe: \
>>$@
# Executing test suite
.PHONY: test debugtest
test: $(OPT)
../test/core/run.py --wasm `pwd`/$(OPT) $(if $(JS),--js '$(JS)',)
debugtest: $(UNOPT)
../test/core/run.py --wasm `pwd`/$(UNOPT) $(if $(JS),--js '$(JS)',)
test/%: $(OPT)
../test/core/run.py --wasm `pwd`/$(OPT) $(if $(JS),--js '$(JS)',) $(@:test/%=../test/core/%.wast)
debugtest/%: $(UNOPT)
../test/core/run.py --wasm `pwd`/$(UNOPT) $(if $(JS),--js '$(JS)',) $(@:debugtest/%=../test/core/%.wast)
run/%: $(OPT)
./$(OPT) $(@:run/%=../test/core/%.wast)
debug/%: $(UNOPT)
./$(UNOPT) $(@:debug/%=../test/core/%.wast)
# Miscellaneous targets
.PHONY: clean
$(ZIP): $(WINMAKE)
git archive --format=zip --prefix=$(NAME)/ -o $@ HEAD
clean:
rm -rf _build/jslib $(LIB).mlpack _tags
$(OCB) -clean
# Opam support
.PHONY: check install uninstall
check:
# Check that we can find all relevant libraries
# when using ocamlfind
ocamlfind query $(LIBS)
install: _build/$(LIB).cmx _build/$(LIB).cmo
ocamlfind install $(LIB) meta/findlib/META _build/$(LIB).o \
$(wildcard _build/$(LIB).cm*) \
$(wildcard $(DIRS:%=%/*.mli))
uninstall:
ocamlfind remove $(LIB)