-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
125 lines (92 loc) · 3.19 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
################################################################################
#
# (c) Copyright IBM Corp. 2016, 2017
#
# This program and the accompanying materials are made available
# under the terms of the Eclipse Public License v1.0 and
# Apache License v2.0 which accompanies this distribution.
#
# The Eclipse Public License is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# The Apache License v2.0 is available at
# http://www.opensource.org/licenses/apache2.0.php
#
# Contributors:
# Multiple authors (IBM Corp.) - initial implementation and documentation
#
################################################################################
CC?= gcc
CXX?= g++
BUILD_CONFIG?= opt
ifeq ($(BUILD_CONFIG),debug)
LUA_BUILD_CONFIG_FLAGS= -O0 -g
LVJIT_BUILD_CONFIG_FLAGS= -O0 -g
JITBUILDER_BUILD_CONFIG_FLAGS= -O0 -g
JITBUILDER_BUILD_CONFIG_VARS= BUILD_CONFIG=debug
else ifeq ($(BUILD_CONFIG),opt)
LUA_BUILD_CONFIG_FLAGS= -O2 -g
LVJIT_BUILD_CONFIG_FLAGS= -O3 -g
JITBUILDER_BUILD_CONFIG_FLAGS= -O3 -g
JITBUILDER_BUILD_CONFIG_VARS=
else ifeq ($(BUILD_CONFIG),prod)
LUA_BUILD_CONFIG_FLAGS= -O2
LVJIT_BUILD_CONFIG_FLAGS= -O3
JITBUILDER_BUILD_CONFIG_FLAGS= -O3
JITBUILDER_BUILD_CONFIG_VARS= BUILD_CONFIG=prod ASSUMES=
endif
LUAV?= luav
LUA_APP?= lua.o
LUA_LIB?= liblua.a
LVJIT_LIB?= liblvjit.a
JITBUILDER_LIB?= libjitbuilder.a
LUA_DIR?= $(PWD)/lua
LVJIT_DIR?= $(PWD)/lvjit
JITBUILDER_DIR?= $(PWD)/omr/jitbuilder
LUA_LIBPATH?= $(LUA_DIR)/$(LUA_LIB)
LVJIT_LIBPATH?= $(LVJIT_DIR)/$(LVJIT_LIB)
JITBUILDER_LIBPATH?= $(JITBUILDER_DIR)/release/$(JITBUILDER_LIB)
# targets
.PHONY: all $(LUA_DIR)/lua.o $(LUA_LIBPATH) $(LVJIT_LIBPATH) $(JITBUILDER_LIBPATH)
all: $(LUAV)
$(LUAV): $(LUA_DIR)/lua.o $(LUA_LIBPATH) $(LVJIT_LIBPATH) $(JITBUILDER_LIBPATH)
$(CXX) -o $@ $(LUA_DIR)/lua.o $(LUA_LIBPATH) $(LVJIT_LIBPATH) $(JITBUILDER_LIBPATH) -ldl -lm -lreadline
$(LUA_DIR)/lua.o:
cd $(LUA_DIR) && $(MAKE) lua.o SYSCFLAGS="-DLUA_USE_LINUX" MYCFLAGS="$(LUA_BUILD_CONFIG_FLAGS)"
$(LUA_LIBPATH):
cd $(LUA_DIR) && $(MAKE) $(LUA_LIB) SYSCFLAGS="-DLUA_USE_LINUX" MYCFLAGS="$(LUA_BUILD_CONFIG_FLAGS)"
$(LVJIT_LIBPATH):
cd $(LVJIT_DIR) && $(MAKE) $@ CXX="$(CXX)" CXX_FLAGS_EXTRA="-fpermissive -DLUA_C_LINKAGE $(LVJIT_BUILD_CONFIG_FLAGS)"
$(JITBUILDER_LIBPATH):
cd $(JITBUILDER_DIR) && $(MAKE) CXX="$(CXX)" CXX_FLAGS_EXTRA="$(JITBUILDER_BUILD_CONFIG_FLAGS)" $(JITBUILDER_BUILD_CONFIG_VARS)
# clean rules
clean:
cd $(LUA_DIR) && $(MAKE) clean
cd $(LVJIT_DIR) && $(MAKE) clean
cleanlibs:
rm -f $(LUA_DIR)/lua.o $(LUA_LIBPATH) $(LVJIT_LIBPATH) $(JITBUILDER_LIBPATH)
cleanlua:
cd $(LUA_DIR) && $(MAKE) clean
cleanlvjit:
cd $(LVJIT_DIR) && $(MAKE) cleanall
cleanjitbuilder:
cd $(JITBUILDER_DIR) && $(MAKE) clean
cleanall:
cd $(LUA_DIR) && $(MAKE) clean
cd $(LVJIT_DIR) && $(MAKE) cleanall
cd $(JITBUILDER_DIR) && $(MAKE) clean
# test rules
.PHONY: test
test:
cd test/lvjit && make
cd test/control && ../../$(LUAV) all.lua
cd test/opcode && ../../$(LUAV) all.lua
# lua patch
# version of lua to diff against
LUA?=luavm
# commit with the applied changes
COMMIT?=HEAD
PATCH_DEST?=$(PWD)
PATCH_FILE?=$(LUA)-$(COMMIT).patch
lua-patch:
git diff $(LUA) $(COMMIT) -- lua/* > $(PATCH_DEST)/$(PATCH_FILE)