-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
72 lines (53 loc) · 1.74 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
CC = g++
CFLAGS = -Wall -pedantic -g -O0
YFLAGS = --verbose --debug --defines
LFLAGS = --yylineno
ODIR = obj
#A list of all objects our compiler needs to link into the executable
OBJS = NArrayAccess.o NAssignment.o NBinOp.o NCharLit.o NCodeBlock.o\
NConditional.o NDec.o NDeclarationBlock.o NEndIf.o NFunctionDeclaration.o\
NIdentifier.o NInc.o NInput.o NInteger.o NLoop.o NMethodCall.o Node.o\
NNullToken.o NParamBlock.o NParamDeclarationBlock.o NPrint.o NReturn.o\
NStatementList.o NStringLit.o NUnaryOp.o NVariableDeclaration.o TypeMap.o\
SemanticErrors.o TreePrinter.o SymbolTableGenerator.o SymbolTable.o\
FileLocation.o GenericASTVisitor.o LabelMaker.o CodeGenerator.o \
x86CodeGenerator.o ARMCodeGenerator.o TreeOptimiser.o RefCountGenerator.o\
TreeGrapher.o
# Messy but cant find a nicer way at present
OBJ=$(patsubst %,$(ODIR)/%,$(OBJS))
all: lex.yy.c y.tab.c compile
lex.yy.c: lexer.l
flex $(LFLAGS) lexer.l
scanner: lex.yy.c y.tab.h
$(CC) $(CFLAGS) $^ -ll -o $@
y.tab.c: grammar.y
yacc $(YFLAGS) grammar.y
compile: lex.yy.c y.tab.c $(OBJ)
$(CC) $(CFLAGS) $^ -o $@ -lfl -lboost_graph
graph: graph.gv
dot -v -Tpdf graph.gv -o graph.pdf
#Each Subdirectory makes all its files and places them in obj
$(ODIR)/%.o: TreeUtils/%.cpp
$(CC) $(CFLAGS) -c -o $@ $<
$(ODIR)/%.o: Errors/%.cpp
$(CC) $(CFLAGS) -c -o $@ $<
$(ODIR)/%.o: SymbolTable/%.cpp
$(CC) $(CFLAGS) -c -o $@ $<
$(ODIR)/%.o: FileLocation/%.cpp
$(CC) $(CFLAGS) -c -o $@ $<
$(ODIR)/%.o : CodeGeneration/%.cpp
$(CC) $(CFLAGS) -c -o $@ $<
$(ODIR)/%.o : Node/%.cpp
$(CC) $(CFLAGS) -c -o $@ $<
hello: hello.asm
nasm -f elf64 hello.asm
clean:
rm -f $(ODIR)/*.o
rm -f lex.yy.c
rm -f scanner
rm -f compile
rm -f y.tab.c
rm -f y.output
rm -f y.tab.h
rm -f graph.*
.PHONY: clean all