-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
52 lines (41 loc) · 1.05 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
# Build Cminus Compiler
# 16 April, 2018 - Cameron Tauxe
all: cminus clean
#link object files (lex must be compiled before yacc)
cminus: lex.yy.o y.tab.o common.o ast.o symtab.o emit.o
gcc -o cminus lex.yy.o y.tab.o common.o ast.o symtab.o emit.o
#Compile lex.yy.o (requires yacc output first)
lex.yy.o: lex.yy.c y.tab.c
gcc -c lex.yy.c
# Get Lex output (with header file)
lex.yy.c: cminus_lex.l
lex cminus_lex.l
#Compile y.tab.o (yacc output should already be generated)
y.tab.o:
gcc -c y.tab.c
# Get Yacc output (also generates header file)
#update if headers change
y.tab.c: cminus_yacc.y common.h ast.h symtab.h
yacc -d cminus_yacc.y
#Compile common
common.o: common.c common.h
gcc -c common.c
# Compile ast
ast.o: ast.c ast.h common.h
gcc -c ast.c
# Compile symtab
symtab.o: symtab.c symtab.h common.h
gcc -c symtab.c
# Compile emit
emit.o: emit.c emit.h common.h
gcc -c emit.c
clean:
rm y.tab.o
rm common.o
rm ast.o
rm symtab.o
rm emit.o
rm lex.yy.o
rm y.tab.c
rm y.tab.h
rm lex.yy.c