]> git.lizzy.rs Git - metalua.git/blob - src/compiler/Makefile
02f1b42f523aed5d7ef293bf2fc637ab9429e2a6
[metalua.git] / src / compiler / Makefile
1 include ../config
2
3 all: $(LIBRARIES) install metalua
4
5 $(PLATFORM): all
6
7 LUA_RUN     = ../$(LUA_VM_DIR)/$(RUN)
8 LUA_COMPILE = ../$(LUA_VM_DIR)/$(COMPILE)
9
10 LIBRARIES =       \
11         bytecode.luac \
12         mlp.luac      \
13         mlc.luac      
14
15 # Library which compiles an AST into a bytecode string.
16 BYTECODE_LUA =      \
17       lopcodes.lua  \
18       lcode.lua     \
19       ldump.lua     \
20       compile.lua   
21
22 # Library which compiles source strings into AST
23 MLP_LUA =           \
24       lexer.lua     \
25       gg.lua        \
26       mlp_lexer.lua \
27       mlp_misc.lua  \
28       mlp_table.lua \
29       mlp_meta.lua  \
30       mlp_expr.lua  \
31       mlp_stat.lua  \
32       mlp_ext.lua 
33
34 metalua.luac: mlc.luac
35
36 bytecode.luac: $(BYTECODE_LUA)
37         $(LUA_COMPILE) -o $@ $^
38
39 mlp.luac: $(MLP_LUA)
40         $(LUA_COMPILE) -o $@ $^
41
42 # Plain lua files compilation
43 %.luac: %.mlua bootstrap.lua mlp.luac bytecode.luac
44         $(LUA_RUN) bootstrap.lua $<
45
46 # FIXME what's this?! some old stuff from when metalua files hadn't their own
47 # extensions?
48 # Metalua files compilation through the bootstrap compiler
49 %.luac: %.lua
50         $(LUA_COMPILE) -o $@ bootstrap $<
51
52 # Compiler/interpreter
53 metalua: metalua.luac $(LIBRARIES)
54         $(LUA_RUN) metalua.luac --verbose --sharpbang '#!$(TARGET_BIN_PATH)/lua' --output metalua --file metalua.mlua
55
56 install: metalua $(LIBRARIES)
57         mkdir -p $(TARGET_BIN_PATH)
58         cp metalua $(TARGET_BIN_PATH)/
59         mkdir -p $(TARGET_LUA_PATH)
60         cp $(LIBRARIES) $(TARGET_LUA_PATH)/
61
62 .PHONY: all install
63
64 clean:
65         -rm *.luac metalua