forked from lsegal/my_toy_compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
39 lines (28 loc) · 738 Bytes
/
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
all: parser
OBJS = parser.o \
codegen.o \
main.o \
tokens.o \
corefn.o \
native.o \
LLVMCONFIG = llvm-config
CPPFLAGS = `$(LLVMCONFIG) --cppflags` -std=c++11
LDFLAGS = `$(LLVMCONFIG) --ldflags` -lpthread -ldl -lncurses -rdynamic
LIBS = `$(LLVMCONFIG) --libs`
clean:
$(RM) -rf parser.cpp parser.hpp parser tokens.cpp $(OBJS) out.ll prog.s prog.o prog
parser.cpp: parser.y
bison -d -o $@ $^
parser.hpp: parser.cpp
tokens.cpp: tokens.l parser.hpp
flex -o $@ $^
%.o: %.cpp
g++ -c $(CPPFLAGS) -o $@ $<
parser: $(OBJS)
g++ -o $@ $(OBJS) $(LIBS) $(LDFLAGS)
test: parser example.txt
cat example.txt | ./parser
exec:
llc -o prog.s out.ll
as -o prog.o prog.s
gcc -o prog prog.o native.o