-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (52 loc) · 2.01 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
CXXFLAGS = \
-O3 --std=c++17 -Wall -Wextra -Werror -pedantic \
-Wcast-align -Wcast-qual -Wmissing-declarations \
-Wold-style-cast -Woverloaded-virtual -Wsign-promo
COMPILER_EXE = monkey-compiler
COMPILER_BENCHMARK_EXE = benchmark-compiler
INTERPRETER_EXE = monkey-interpreter
INTERPRETER_BENCHMARK_EXE = benchmark-interpreter
COMPILER_DIR = ./compiler
INTERPRETER_DIR = ./interpreter
COMPILER_SRC = \
$(COMPILER_DIR)/ast.cpp \
$(COMPILER_DIR)/builtins.cpp \
$(COMPILER_DIR)/code.cpp \
$(COMPILER_DIR)/compiler.cpp \
$(COMPILER_DIR)/frame.cpp \
$(COMPILER_DIR)/lexer.cpp \
$(COMPILER_DIR)/object.cpp \
$(COMPILER_DIR)/parser.cpp \
$(COMPILER_DIR)/symbol_table.cpp \
$(COMPILER_DIR)/token.cpp \
$(COMPILER_DIR)/vm.cpp
INTERPRETER_SRC = \
$(INTERPRETER_DIR)/ast.cpp \
$(INTERPRETER_DIR)/builtins.cpp \
$(INTERPRETER_DIR)/evaluator.cpp \
$(INTERPRETER_DIR)/lexer.cpp \
$(INTERPRETER_DIR)/object.cpp \
$(INTERPRETER_DIR)/parser.cpp \
$(INTERPRETER_DIR)/repl.cpp \
$(INTERPRETER_DIR)/token.cpp
COMPILER_OBJ = $(COMPILER_SRC:.cpp=.o)
INTERPRETER_OBJ = $(INTERPRETER_SRC:.cpp=.o)
.PHONY: all clean compiler compiler-benchmark interpreter interpreter-benchmark
all: compiler interpreter
compiler : $(COMPILER_EXE)
$(COMPILER_EXE) : $(COMPILER_OBJ) $(COMPILER_DIR)/monkey.o $(COMPILER_DIR)/repl.o
$(CXX) $(CXXFLAGS) $^ -o $@
compiler-benchmark : $(COMPILER_BENCHMARK_EXE)
$(COMPILER_BENCHMARK_EXE) : $(COMPILER_OBJ) $(COMPILER_DIR)/benchmark.o
$(CXX) $(CXXFLAGS) $^ -o $@
$(COMPILER_OBJ): $(COMPILER_INC)
interpreter : $(INTERPRETER_EXE)
$(INTERPRETER_EXE) : $(INTERPRETER_OBJ) $(INTERPRETER_DIR)/monkey.o $(INTERPRETER_DIR)/repl.o
$(CXX) $(CXXFLAGS) $^ -o $@
interpreter-benchmark : $(INTERPRETER_BENCHMARK_EXE)
$(INTERPRETER_BENCHMARK_EXE) : $(INTERPRETER_OBJ) $(INTERPRETER_DIR)/benchmark.o
$(CXX) $(CXXFLAGS) $^ -o $@
$(INTERPRETER_OBJ): $(INTERPRETER_INC)
clean :
rm -rf $(COMPILER_DIR)/*.o $(COMPILER_EXE) $(COMPILER_BENCHMARK_EXE)
rm -rf $(INTERPRETER_DIR)/*.o $(INTERPRETER_EXE) $(INTERPRETER_BENCHMARK_EXE)