-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile.bak
85 lines (61 loc) · 2.31 KB
/
Makefile.bak
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
##
## Simple makefile for CS143 programming projects
##
.PHONY: clean strip
# Set the default target. When you make with no arguments,
# this will be the target built.
COMPILER = dcc
PRODUCTS = $(COMPILER)
default: $(PRODUCTS)
# Set up the list of source and object files
SRCS = ast.cc ast_decl.cc ast_expr.cc ast_stmt.cc ast_type.cc codegen.cc tac.cc mips.cc errors.cc utility.cc main.cc
# OBJS can deal with either .cc or .c files listed in SRCS
OBJS = y.tab.o lex.yy.o $(patsubst %.cc, %.o, $(filter %.cc,$(SRCS))) $(patsubst %.c, %.o, $(filter %.c, $(SRCS)))
JUNK = *.o lex.yy.c dpp.yy.c y.tab.c y.tab.h *.core core *~
# Define the tools we are going to use
CC= g++
LD = g++
LEX = flex
YACC = bison
# Set up the necessary flags for the tools
# We want debugging and most warnings, but lex/yacc generate some
# static symbols we don't use, so turn off unused warnings to avoid clutter
# Also STL has some signed/unsigned comparisons we want to suppress
CFLAGS = -g -Wall -Wno-unused -Wno-sign-compare
# The -d flag tells lex to set up for debugging. Can turn on/off by
# setting value of global yy_flex_debug inside the scanner itself
LEXFLAGS = -d
# The -d flag tells yacc to generate header with token types
# The -v flag writes out a verbose description of the states and conflicts
# The -t flag turns on debugging capability
# The -y flag means imitate yacc's output file naming conventions
YACCFLAGS = -dvty
# Link with standard C library, math library, and lex library
LIBS = -lc -lm -ll
# Rules for various parts of the target
.yy.o: $*.yy.c
$(CC) $(CFLAGS) -c -o $@ $*.cc
lex.yy.c: scanner.l parser.y y.tab.h
$(LEX) $(LEXFLAGS) scanner.l
y.tab.o: y.tab.c
$(CC) $(CFLAGS) -c -o y.tab.o y.tab.c
y.tab.h y.tab.c: parser.y
$(YACC) $(YACCFLAGS) parser.y
.cc.o: $*.cc
$(CC) $(CFLAGS) -c -o $@ $*.cc
# rules to build compiler (dcc)
$(COMPILER) : $(OBJS)
$(LD) -o $@ $(OBJS) $(LIBS)
# This target is to build small for testing (no debugging info), removes
# all intermediate products, too
strip : $(PRODUCTS)
strip $(PRODUCTS)
rm -rf $(JUNK)
# make depend will set up the header file dependencies for the
# assignment. You should make depend whenever you add a new header
# file to the project or move the project between machines
#
depend:
makedepend -- $(CFLAGS) -- $(SRCS)
clean:
rm -f $(JUNK) y.output $(PRODUCTS)