-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
119 lines (84 loc) · 2.84 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
###
# This Makefile can be used to make a parser for the C-- language
# (parser.class) and to make a program (P4.class) that tests the parser and
# the unparse methods in ast.java.
#
# make clean removes all generated files.
#
###
JCC = javac
JVM = java
SRCDIR = src
DEPDIR = deps
TESTDIR = test
DEMODIR = demo
CP = $(SRCDIR):$(DEPDIR)
CPFLAGS = -cp $(CP)
JFLAGS = -g $(CPFLAGS)
SRCEXT = java
CLSEXT = class
ASEXT = s
SRC = $(wildcard $(SRCDIR)/*.$(SRCEXT))
CLS = $(SRC:.$(SRCEXT)=.$(CLSEXT))
VPATH = $(SRCDIR):$(DEPDIR)
RM = rm
RMFLAGS = -f
RMTARGETS = $(addprefix $(SRCDIR)/, *~ *.class parser.java CMM.jlex.java sym.java) $(TESTDIR)/*.$(ASEXT)
.SUFFIXES: .java .class
.PHONY: clean
# NOTE: Needed to hackily move/remove some files that end up in the root project directory
# post-compilation. This should probably be fixed.
CompilerTester.class: CompilerTester.java parser.class Yylex.class ASTnode.class
$(JCC) $(JFLAGS) $(CPFLAGS) $<
@rm -f ./parser.java
parser.class: $(SRCDIR)/parser.java ASTnode.class Yylex.class ErrMsg.class
$(JCC) $(CPFLAGS) $<
$(SRCDIR)/parser.java: CMM.cup
$(JVM) $(CPFLAGS) java_cup.Main < $<
@mv ./parser.java $(SRCDIR)/parser.java
Yylex.class: $(SRCDIR)/CMM.jlex.java sym.class ErrMsg.class
$(JCC) $(CPFLAGS) $<
ASTnode.class: ast.java Type.java
$(JCC) $(JFLAGS) $(CPFLAGS) $<
$(SRCDIR)/CMM.jlex.java: CMM.jlex sym.class
$(JVM) $(CPFLAGS) JLex.Main $<
sym.class: $(SRCDIR)/sym.java
$(JCC) $(JFLAGS) $(CPFLAGS) $<
$(SRCDIR)/sym.java: CMM.cup
$(JVM) $(CPFLAGS) java_cup.Main < $<
@mv ./sym.java $(SRCDIR)/sym.java
ErrMsg.class: ErrMsg.java
$(JCC) $(CPFLAGS) $<
Sym.class: Sym.java Type.java ast.java
$(JCC) $(JFLAGS) $(CPFLAGS) $<
SymTable.class: SymTable.java Sym.java DuplicateSymException.java EmptySymTableException.java
$(JCC) $(JFLAGS) $(CPFLAGS) $<
Type.class: Type.java
$(JCC) $(JFLAGS) $(CPFLAGS) $<
DuplicateSymException.class: DuplicateSymException.java
$(JCC) $(JFLAGS) $(CPFLAGS) $<
EmptySymTableException.class: EmptySymTableException.java
$(JCC) $(JFLAGS) $(CPFLAGS) $<
Codegen.class: Codegen.java
$(JCC) $(CPFLAGS) $<
# %.$(CLSEXT) : %.$(SRCEXT)
# $(JCC) $(JFLAGS) $<
# CompilerTester.class: parser.class Yylex.class ASTnode.class
# parser.class: ASTnode.class Yylex.class ErrMsg.class
# parser.java: CMM.cup
# $(JVM) $(CPFLAGS) java_cup.Main < $<
# Yylex.class: CMM.jlex.java sym.class ErrMsg.class
# $(JCC) $(CPFLAGS) $<
# ASTnode.class: ast.java Type.java
# $(JCC) $(JFLAGS) $<
# CMM.jlex.java: CMM.jlex sym.class
# $(JVM) $(CPFLAGS) JLex.Main $<
# sym.java: CMM.cup
# $(JVM) $(CPFLAGS) java_cup.Main < $<
# Sym.class: Type.java ast.java
# SymTable.class: Sym.java DuplicateSymException.java EmptySymTableException.java
###
# clean
###
clean:
$(RM) $(RMFLAGS) $(RMTARGETS)