]> git.lizzy.rs Git - metalua.git/blob - src/compiler/Makefile
Merge branch 'master' of git+ssh://fab13n@repo.or.cz/srv/git/metalua
[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 bytecode.luac: $(BYTECODE_LUA)
35         $(LUA_COMPILE) -o $@ $^
36
37 mlp.luac: $(MLP_LUA)
38         $(LUA_COMPILE) -o $@ $^
39
40 # Plain lua files compilation
41 %.luac: %.mlua bootstrap.lua mlp.luac bytecode.luac
42         $(LUA_RUN) bootstrap.lua $<
43
44 # Metalua files compilation through the bootstrap compiler
45 %.luac: %.lua
46         $(LUA_COMPILE) -o $@ bootstrap $<
47
48 # Compiler/interpreter
49 metalua: metalua.luac $(LIBRARIES)
50         $(LUA_RUN) metalua.luac --verbose --sharpbang '#!/usr/bin/env lua' --output metalua --file metalua.mlua
51
52 install: metalua $(LIBRARIES)
53         mkdir -p $(TARGET_BIN_PATH)
54         cp metalua $(TARGET_BIN_PATH)/
55         mkdir -p $(TARGET_LUA_PATH)
56         cp $(LIBRARIES) $(TARGET_LUA_PATH)/
57
58 .PHONY: all install
59
60 clean:
61         -rm *.luac metalua