| 1 | #
|
---|
| 2 | # Makefile for assignment 3 of the Compiler Construction course.
|
---|
| 3 | # Fall 2008, 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 | OBJDIR = gen/
|
---|
| 25 | OBJS = $(addprefix $(OBJDIR),$(OBJFILES))
|
---|
| 26 |
|
---|
| 27 | # Precompiled object files
|
---|
| 28 | POBJFILES = types.o SyntaxTree.o Node.o Symbol.o SymbolTable.o Scope.o \
|
---|
| 29 | IntermediateCode.o IStatement.o IOperand.o IOperator.o
|
---|
| 30 | POBJDIR = obj/
|
---|
| 31 | POBJS = $(addprefix $(POBJDIR),$(POBJFILES))
|
---|
| 32 |
|
---|
| 33 | IMPORTANT = comp.[hly] *.h *.c *.cc \
|
---|
| 34 | Makefile
|
---|
| 35 |
|
---|
| 36 | .PHONY: all first clean backup dirs showdeps
|
---|
| 37 |
|
---|
| 38 | all: comp
|
---|
| 39 |
|
---|
| 40 | # To be executed before the very first build
|
---|
| 41 | first: dirs
|
---|
| 42 |
|
---|
| 43 | # Dependency stuff
|
---|
| 44 | comp: $(POBJDIR)y.tab.o $(POBJDIR)lex.yy.o $(OBJS) $(POBJS)
|
---|
| 45 | $(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBS)
|
---|
| 46 |
|
---|
| 47 | clean:
|
---|
| 48 | rm -f $(OBJDIR)*.o comp \
|
---|
| 49 | `find . -name core -o -name \*\.bak`
|
---|
| 50 |
|
---|
| 51 | backup:
|
---|
| 52 | tar cfz ../CoCo-`date +'%y%m%d-%H%M'`.tar.gz $(IMPORTANT)
|
---|
| 53 |
|
---|
| 54 | dirs:
|
---|
| 55 | mkdir gen
|
---|
| 56 |
|
---|
| 57 | # Show dependencies between .c files
|
---|
| 58 | showdeps:
|
---|
| 59 | $(CC) -MM *.c *.cc
|
---|
| 60 |
|
---|
| 61 | # Dependency stuff
|
---|
| 62 | $(OBJDIR)%.o: %.c
|
---|
| 63 | $(CC) $(CFLAGS) -c -o $@ $<
|
---|
| 64 |
|
---|
| 65 | $(OBJDIR)%.o: %.cc
|
---|
| 66 | $(CC) $(CFLAGS) -c -o $@ $<
|
---|