1 | #
|
---|
2 | # Makefile for assignment 4 (and 5) of the Compiler Construction course.
|
---|
3 | # Fall 2007, LIACS, Leiden University.
|
---|
4 | #
|
---|
5 |
|
---|
6 | CC = g++
|
---|
7 | LEX = flex
|
---|
8 | YACC = bison --yacc
|
---|
9 |
|
---|
10 | WARNINGS = -Wall -ansi
|
---|
11 | OTHERS = -m32 -g
|
---|
12 | DEFINES = -DDEBUG
|
---|
13 | IDIRS = -I.
|
---|
14 |
|
---|
15 | CFLAGS = $(WARNINGS) $(OTHERS) $(DEFINES) $(IDIRS)
|
---|
16 | LFLAGS =
|
---|
17 | YFLAGS = --defines --debug --verbose
|
---|
18 | LDFLAGS = -m32 -g
|
---|
19 | LOADLIBS = -lfl -lm
|
---|
20 |
|
---|
21 | # If you want to add another C/C++ file to the compiler, add the name of the
|
---|
22 | # corresponding .o file to the OBJFILES macro below:
|
---|
23 | OBJFILES = debug.o main.o ICGenerator.o \
|
---|
24 | StackFrameManager.o CodeGenerator.o MStatement.o MOperand.o \
|
---|
25 | MOperator.o AssemblerCode.o StackFrameManager.o CodeGenerator.o \
|
---|
26 | RegisterManager.o
|
---|
27 | OBJDIR = gen/
|
---|
28 | OBJS = $(addprefix $(OBJDIR),$(OBJFILES))
|
---|
29 |
|
---|
30 | # Precompiled object files
|
---|
31 | POBJFILES = types.o SyntaxTree.o Node.o Symbol.o SymbolTable.o Scope.o \
|
---|
32 | IntermediateCode.o IStatement.o IOperand.o IOperator.o \
|
---|
33 | ICGenerator0.o
|
---|
34 | POBJDIR = obj/
|
---|
35 | POBJS = $(addprefix $(POBJDIR),$(POBJFILES))
|
---|
36 |
|
---|
37 | IMPORTANT = comp.[hly] *.h *.c *.cc \
|
---|
38 | Makefile
|
---|
39 |
|
---|
40 | .PHONY: all first clean backup dirs showdeps
|
---|
41 |
|
---|
42 | all: comp
|
---|
43 |
|
---|
44 | # To be executed before the very first build
|
---|
45 | first: dirs
|
---|
46 |
|
---|
47 | # Dependency stuff
|
---|
48 | comp: $(POBJDIR)y.tab.o $(POBJDIR)lex.yy.o $(OBJS) $(POBJS)
|
---|
49 | $(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBS)
|
---|
50 |
|
---|
51 | clean:
|
---|
52 | rm -f $(OBJDIR)*.o comp \
|
---|
53 | `find . -name core -o -name \*\.bak`
|
---|
54 |
|
---|
55 | backup:
|
---|
56 | tar cfz ../CoCo-`date +'%y%m%d-%H%M'`.tar.gz $(IMPORTANT)
|
---|
57 |
|
---|
58 | dirs:
|
---|
59 | mkdir gen
|
---|
60 |
|
---|
61 | # Show dependencies between .c files
|
---|
62 | showdeps:
|
---|
63 | $(CC) -MM *.c *.cc
|
---|
64 |
|
---|
65 | # Dependency stuff
|
---|
66 | $(OBJDIR)%.o: %.c
|
---|
67 | $(CC) $(CFLAGS) -c -o $@ $<
|
---|
68 |
|
---|
69 | $(OBJDIR)%.o: %.cc
|
---|
70 | $(CC) $(CFLAGS) -c -o $@ $<
|
---|
71 |
|
---|
72 | bt: all
|
---|
73 | gdb -x gdb.script ./comp
|
---|