-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
106 lines (72 loc) · 2.51 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
OBJ_DIR = build
# complier
TARGET = bin/zcc
# use it to deal grammar
TOOL = bin/parsingtable_creater
OBJFS = main.o tokenizer.o token.o parser.o grammar.o parsing_table.o \
translate.o code.o codemanager.o symboltable.o symboltablemanager.o \
error.o asm.o
OBJFS_GRAMMAR = pmain.o grammar_tool.o token.o error.o grammar.o \
parsing_table.o status.o dfa.o
OBJECTS = $(patsubst %.o, $(OBJ_DIR)/%.o, $(OBJFS))
OBJECTS_GRAMMAR = $(patsubst %.o, $(OBJ_DIR)/%.o, $(OBJFS_GRAMMAR))
CC = g++
INCLUDE = -Iinclude -Iinclude/lex -Iinclude/parser -Iinclude/symboltable \
-Iinclude/utils -Iinclude/tools/grammar -Iinclude/translate -Iinclude/asm
CPPFLAGS = -Wall -std=c++11 $(INCLUDE)
all:$(TARGET) $(TOOL)
tool:$(TOOL)
$(TARGET): prepare $(OBJECTS)
$(CC) $(CPPFLAGS) -o $(TARGET) $(OBJECTS)
$(TOOL): prepare $(OBJECTS_GRAMMAR)
$(CC) $(CPPFLAGS) -o $(TOOL) $(OBJECTS_GRAMMAR)
prepare:
@-mkdir -p bin
@-mkdir -p build
# zcc main
$(OBJ_DIR)/main.o: src/main.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/tokenizer.o:src/lex/tokenizer.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/token.o:src/lex/token.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/parser.o:src/parser/parser.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/grammar.o:src/parser/grammar.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/parsing_table.o:src/parser/parsing_table.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/translate.o:src/translate/translate.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/code.o:src/translate/code.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/codemanager.o:src/translate/codemanager.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/symboltable.o:src/symboltable/symboltable.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/symboltablemanager.o:src/symboltable/symboltablemanager.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/error.o:src/utils/error.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/asm.o:src/asm/asm.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
# just used by grammar tool
# grammar tool main
$(OBJ_DIR)/pmain.o: src/pmain.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/grammar_tool.o: src/tools/parsingtable_creater/grammar_tool.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/dfa.o: src/tools/parsingtable_creater/dfa.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
$(OBJ_DIR)/status.o: src/tools/parsingtable_creater/status.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
.PHONY: clean
clean:
-rm -rf build/*.o
-rm -rf bin/zcc
-rm -rf bin/parsingtable_creater
.PHONY: windows-clean
wclean:
-rm -rf build/*.o
-rm -rf bin/zcc.exe
-rm -rf bin/parsingtable_creater.exe