-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
233 lines (189 loc) · 7.4 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
LUA = lua
LUAJIT = luajit
NODE = node
MKDIR = mkdir -p
CP = cp -fpR
INSTALL_EXEC = install -p -m 0755
SMLFMT = smlfmt
include version.mk
all: bin/lunarml
sources = \
pluto/token-stream.sig \
pluto/string-stream.sig \
pluto/string-stream.sml \
pluto/parser-combinator.sig \
pluto/parser-combinator.fun \
pluto/char-parser.sig \
pluto/char-parser.fun \
src/compat/ord_set.sig \
src/compat/ord_map.sig \
src/compat/red-black-set-fn.sml \
src/compat/red-black-map-fn.sml \
src/list-util.sml \
src/vector-util.sml \
src/string-set.sml \
src/string-map.sml \
src/numeric.sml \
src/text.sml \
src/strongly-connected-components.sml \
src/language-options-record.sml \
src/language-options.sml \
src/target-info.sml \
src/primitives.sml \
src/syntax.grm.sig \
src/sourcepos.sml \
src/message.sml \
src/tokenizer.sml \
src/syntax.sml \
src/syntax.grm.sml \
src/parser.sml \
src/postparsing.sml \
src/typed.sml \
src/typing.sml \
src/initialenv.sml \
src/printer.sml \
src/fsyntax.sml \
src/fprinter.sml \
src/pattern-match.sml \
src/ftransform.sml \
src/cps.sml \
src/cps/dead-code.sml \
src/cps/uncurry.sml \
src/cps/loop.sml \
src/cps/ref-cell.sml \
src/cps/inline.sml \
src/cps/decompose-recursive.sml \
src/cps/unpack-record-parameter.sml \
src/cps/eta.sml \
src/backend.sml \
src/nested.sml \
src/lua-syntax.sml \
src/lua-transform.sml \
src/codegen-lua.sml \
src/js-syntax.sml \
src/js-transform.sml \
src/codegen-js.sml \
src/mlb-syntax.sml \
src/mlb-parser.sml \
src/driver.sml \
src/mlb-eval.sml \
src/command-line-settings.sml \
src/version.sml \
src/initfile.sml \
src/main.sml \
src/main-default.sml
autogen_sources = \
src/language-options-record.sml \
src/primitives.sml \
src/syntax.grm.sig \
src/syntax.grm.sml \
src/command-line-settings.sml \
src/version.sml
formatted_sources = \
$(filter-out $(autogen_sources),$(sources)) \
src/main-esmod.sml
typecheck: src/lunarml-main.mlb $(sources)
mlton -stop tc -default-ann "warnUnused true" $<
.PHONY: format
format:
$(SMLFMT) --force $(formatted_sources)
.PHONY: check-format
check-format:
$(SMLFMT) --check $(formatted_sources)
bin/lunarml: src/lunarml-main.mlb $(sources)
mlton -output $@ $<
bin/lunarml.gen2.lua: src/lunarml-main.mlb bin/lunarml $(sources)
bin/lunarml compile --default-ann "valDescInComments error" -o $@ $<
bin/lunarml.gen2-luajit.lua: src/lunarml-main.mlb bin/lunarml $(sources)
bin/lunarml compile --default-ann "valDescInComments error" --luajit -o $@ $<
bin/lunarml.gen2.mjs: src/lunarml-main.mlb bin/lunarml $(sources)
bin/lunarml compile --default-ann "valDescInComments error" --nodejs-cps -o $@ $<
bin/lunarml.lua: bin/lunarml.gen2.lua
echo '#!/usr/bin/env lua' > $@
cat bin/lunarml.gen2.lua >> $@
chmod +x $@
bin/lunarml.mjs: bin/lunarml.gen2.mjs
echo '#!/usr/bin/env node' > $@
cat bin/lunarml.gen2.mjs >> $@
chmod +x $@
src/syntax.grm.sml src/syntax.grm.sig: src/syntax.grm
mlyacc $<
src/primitives.sml: src/primitives.lua
$(LUA) src/primitives.lua $@ > /dev/null
src/command-line-settings.sml: src/command-line-settings.lua util/record.lua
$(LUA) util/record.lua $< > $@
src/language-options-record.sml: src/language-options-record.lua util/record.lua
$(LUA) util/record.lua $< > $@
test: test-lua
test-lua: bin/lunarml
$(MAKE) -C test VARIANT=lua
test-lua-continuations: bin/lunarml
$(MAKE) -C test VARIANT=lua-continuations LUA=$(LUA)
test-luajit: bin/lunarml
$(MAKE) -C test VARIANT=luajit LUAJIT=$(LUAJIT)
test-nodejs: bin/lunarml
$(MAKE) -C test VARIANT=nodejs NODE=$(NODE)
test-nodejs-cps: bin/lunarml
$(MAKE) -C test VARIANT=nodejs-cps NODE=$(NODE)
validate-lua: bin/lunarml
bin/lunarml compile --default-ann "valDescInComments error" -o lunarml.gen2.lua --print-timings src/lunarml-main.mlb
$(LUA) lunarml.gen2.lua -Blib/lunarml compile --default-ann "valDescInComments error" -o lunarml.gen3.lua --print-timings src/lunarml-main.mlb
diff --report-identical-files lunarml.gen2.lua lunarml.gen3.lua
validate-luajit: bin/lunarml
bin/lunarml compile --default-ann "valDescInComments error" -o lunarml.gen2-luajit.lua --luajit --print-timings src/lunarml-main.mlb
$(LUAJIT) lunarml.gen2-luajit.lua -Blib/lunarml compile --default-ann "valDescInComments error" -o lunarml.gen3-luajit.lua --luajit --print-timings src/lunarml-main.mlb
diff --report-identical-files lunarml.gen2-luajit.lua lunarml.gen3-luajit.lua
validate-js: bin/lunarml
bin/lunarml compile --default-ann "valDescInComments error" -o lunarml.gen2.mjs --nodejs-cps --print-timings src/lunarml-main.mlb
$(NODE) lunarml.gen2.mjs -Blib/lunarml compile --default-ann "valDescInComments error" -o lunarml.gen3.mjs --nodejs-cps --print-timings src/lunarml-main.mlb
diff --report-identical-files lunarml.gen2.mjs lunarml.gen3.mjs
verify-lua: bin/lunarml bin/lunarml.gen2.lua
$(MAKE) -C test verify-lua VARIANT=lua LUA=$(LUA) LUNARML_GEN2="$(LUA) ../bin/lunarml.gen2.lua" VARIANT_GEN2=gen2
verify-luajit: bin/lunarml bin/lunarml.gen2-luajit.lua
$(MAKE) -C test verify-luajit VARIANT=luajit LUAJIT=$(LUAJIT) LUNARML_GEN2="$(LUAJIT) ../bin/lunarml.gen2-luajit.lua" VARIANT_GEN2=gen2-luajit
verify-js: bin/lunarml bin/lunarml.gen2.mjs
$(MAKE) -C test verify-nodejs-cps VARIANT=nodejs-cps NODE=$(NODE) LUNARML_GEN2="$(NODE) ../bin/lunarml.gen2.mjs" VARIANT_GEN2=gen2
.PHONY: all typecheck test test-lua test-lua-continuations test-luajit test-nodejs test-nodejs-cps validate-lua validate-luajit validate-js verify-lua verify-luajit verify-js
#
# install
#
PREFIX = /usr/local
libdir = $(PREFIX)/lib/lunarml
install: bin/lunarml
make -C thirdparty install
$(MKDIR) $(PREFIX)/bin $(PREFIX)/lib
sed -e "s;__LIBDIR__;$(libdir);" < bin/lunarml-wrapper > $(PREFIX)/bin/lunarml
chmod a+x $(PREFIX)/bin/lunarml
$(CP) lib/lunarml/ $(PREFIX)/lib/lunarml
$(INSTALL_EXEC) bin/lunarml $(libdir)/lunarml
install-precompiled-lua:
make -C thirdparty install
$(MKDIR) $(PREFIX)/bin $(PREFIX)/lib
sed -e "s;__LIBDIR__;$(libdir);" < bin/lunarml-wrapper > $(PREFIX)/bin/lunarml
chmod a+x $(PREFIX)/bin/lunarml
$(CP) lib/lunarml/ $(PREFIX)/lib/lunarml
$(INSTALL_EXEC) bin/lunarml.lua $(libdir)/lunarml
install-precompiled-node:
make -C thirdparty install
$(MKDIR) $(PREFIX)/bin $(PREFIX)/lib
sed -e "s;__LIBDIR__;$(libdir);" < bin/lunarml-wrapper-node > $(PREFIX)/bin/lunarml
chmod a+x $(PREFIX)/bin/lunarml
$(CP) lib/lunarml/ $(PREFIX)/lib/lunarml
$(INSTALL_EXEC) bin/lunarml.mjs $(libdir)/lunarml.mjs
.PHONY: install install-precompiled-lua install-precompiled-node
#
# install-npm
#
package/npm/lunarml.mjs: src/lunarml-esmod.mlb bin/lunarml $(sources) src/main-esmod.sml
bin/lunarml compile --nodejs-cps --lib --default-ann "valDescInComments error" -o $@ $<
install-npm: package/npm/lunarml.mjs
make -C thirdparty install
cp -R lib/ package/npm/lib
.PHONY: install-npm
#
# archive
#
archive: bin/lunarml.lua bin/lunarml.mjs src/syntax.grm.sml src/syntax.grm.sig
git archive -o "lunarml-$(VERSION).tar.gz" --prefix="lunarml-$(VERSION)/bin/" --add-file=bin/lunarml.lua --add-file=bin/lunarml.mjs --prefix="lunarml-$(VERSION)/src/" --add-file=src/syntax.grm.sml --add-file=src/syntax.grm.sig --prefix="lunarml-$(VERSION)/" HEAD
git archive -o "lunarml-$(VERSION).zip" --prefix="lunarml-$(VERSION)/bin/" --add-file=bin/lunarml.lua --add-file=bin/lunarml.mjs --prefix="lunarml-$(VERSION)/src/" --add-file=src/syntax.grm.sml --add-file=src/syntax.grm.sig --prefix="lunarml-$(VERSION)/" HEAD
.PHONY: archive