-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
63 lines (42 loc) · 1.27 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
SHELL := /bin/bash
CC = g++
CPPFLAGS += -std=c++11 -g
CPPFLAGS += -I include
# for production
CPPFLAGS += -o2
# for debug
#CPPFLAGS += -fmax-errors=5 -ggdb -W -Wall -Wno-unused-parameter
.PHONY: all clean debug
bin/c_compiler : src/c_compiler.o src/C90_parser.tab.o src/C90_lexer.yy.o src/C90_parser.tab.o include/Mp.o include/Context.o
mkdir -p bin
g++ $(CPPFLAGS) -o $@ $^
rm -f src/*.o
rm -f include/*.o
src/C90_parser.tab.cpp src/C90_parser.tab.hpp : src/C90.y
bison -v -d src/C90.y -o src/C90_parser.tab.cpp
src/C90_lexer.yy.cpp : src/C90.flex src/C90_parser.tab.hpp
flex -o src/C90_lexer.yy.cpp src/C90.flex
include/%.o : include/%.cpp
$(CC) $(CPPFLAGS) -c $< -o $@
clean :
rm -f src/*.o
rm -f include/*.o
rm -f bin/*
rm -f src/*.tab.cpp
rm -f src/*.yy.cpp
rm -f tmp/*.py
rm -f test/C_output/*
rm -f test/C_driver_exec/*
rm -f test/dump/*
.PHONY test:testbench.sh
./testbench.sh
# ########### below are debug short cut ###########
all : clean ./bin/c_compiler r
debug: clean ./bin/c_compiler d
r:
./bin/c_compiler --translate test.c -o x.py
# ./bin/c_compiler -S test.c -o x.s
cat x.py
d:
gdb --args ./bin/c_compiler --translate test.c -o x.py
# gdb --args ./bin/c_compiler -S test.c -o x.s