-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
115 lines (93 loc) · 2.53 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
include mk/common.mk
CXXFLAGS := -O2 -g -Wall -Wextra -Wno-c99-designator
CXXFLAGS += -I src
CXXFLAGS += -std=gnu++20 -fno-rtti -fexceptions
LDFLAGS :=
OUT ?= build
# AsmJit
ASMJIT_DIR = external/asmjit/src
CXXFLAGS += -I $(ASMJIT_DIR)
CXXFLAGS += \
-D ASMJIT_EMBED \
-D ASMJIT_BUILD_RELEASE \
-D ASMJIT_NO_LOGGING \
-D ASMJIT_NO_DEPRECATED \
-D ASMJIT_NO_AARCH32 -D ASMJIT_NO_AARCH64 \
-D ASMJIT_NO_FOREIGN \
-D ASMJIT_NO_COMPILER
ASMJIT_SRCS := \
$(wildcard $(ASMJIT_DIR)/asmjit/core/*.cpp) \
$(wildcard $(ASMJIT_DIR)/asmjit/x86/*.cpp)
LDFLAGS += -lrt
OBJS := $(patsubst $(ASMJIT_DIR)/%.cpp,%.o,$(ASMJIT_SRCS))
OBJS += \
util/common.o \
\
arena.o \
mmu.o \
execute.o \
env.o \
tcache.o \
runtime_stubs.o \
\
ir/compile.o \
ir/qir.o \
ir/qir_opt.o \
\
codegen/arch_traits.o \
codegen/jitabi.o \
codegen/qcg.o \
codegen/emit.o \
codegen/regalloc.o \
codegen/select.o \
\
guest/rv32_interp.o \
guest/rv32_qir.o \
\
main.o
OBJS := $(addprefix $(OUT)/, $(OBJS))
deps := $(OBJS:%.o=%.o.d)
BIN = $(OUT)/rv32jit
all: $(BIN)
.ONESHELL:
$(ASMJIT_DIR)/asmjit/asmjit.h:
$(Q)git submodule update --init external/asmjit
$(VECHO) "Please run 'make' again\n" && exit 1
$(OUT)/asmjit/core/%.o: $(ASMJIT_DIR)/asmjit/core/%.cpp
$(VECHO) " CXX\t$@\n"
$(Q)$(CXX) -o $@ $(CXXFLAGS) -c -MMD -MF [email protected] $<
$(OUT)/asmjit/x86/%.o: $(ASMJIT_DIR)/asmjit/x86/%.cpp
$(VECHO) " CXX\t$@\n"
$(Q)$(CXX) -o $@ $(CXXFLAGS) -c -MMD -MF [email protected] $<
$(OUT)/%.o: src/%.cpp
$(VECHO) " CXX\t$@\n"
$(Q)$(CXX) -o $@ $(CXXFLAGS) -c -MMD -MF [email protected] $<
$(OUT)/util/%.o: src/util/%.cpp
$(VECHO) " CXX\t$@\n"
$(Q)$(CXX) -o $@ $(CXXFLAGS) -c -MMD -MF [email protected] $<
$(OUT)/ir/%.o: src/ir/%.cpp
$(VECHO) " CXX\t$@\n"
$(Q)$(CXX) -o $@ $(CXXFLAGS) -c -MMD -MF [email protected] $<
$(OUT)/codegen/%.o: src/codegen/%.cpp
$(VECHO) " CXX\t$@\n"
$(Q)$(CXX) -o $@ $(CXXFLAGS) -c -MMD -MF [email protected] $<
$(OUT)/guest/%.o: src/guest/%.cpp
$(VECHO) " CXX\t$@\n"
$(Q)$(CXX) -o $@ $(CXXFLAGS) -c -MMD -MF [email protected] $<
SHELL_HACK := $(shell mkdir -p $(OUT) $(OUT)/util $(OUT)/ir $(OUT)/codegen $(OUT)/guest $(OUT)/asmjit/core $(OUT)/asmjit/x86)
$(OUT)/rv32jit: $(ASMJIT_DIR)/asmjit/asmjit.h $(OBJS)
$(VECHO) " LD\t$@\n"
$(Q)$(CXX) -o $@ $(CXXFLAGS) $(OBJS) $(LDFLAGS)
# Rules for downloading prebuilt RISC-V ELF files
include mk/external.mk
check: $(BIN) $(CHECK_ELF_FILES)
$(Q)$(foreach e,$(CHECK_ELF_FILES),\
$(PRINTF) "Running $(e) ...\n"; \
$(BIN) $(e) && $(call notice, [OK]); \
)
# Tests
include mk/tests.mk
.PHONY: clean
clean:
$(RM) $(BIN) $(OBJS) $(deps)
-include $(deps)