# # Makefile for assignment 2 of the Compiler Construction course. # Fall 2007, LIACS, Leiden University. # CC = g++ LEX = flex YACC = bison --yacc WARNINGS = -Wall -ansi OTHERS = -m32 -g DEFINES = -DDEBUG IDIRS = -I. CFLAGS = $(WARNINGS) $(OTHERS) $(DEFINES) $(IDIRS) LFLAGS = YFLAGS = --defines --debug --verbose LDFLAGS = -m32 -g LOADLIBS = -lfl -lm # # If you want to add another C/C++ file to the compiler, add the name of the # corresponding .o file to the OBJFILES macro below: # OBJFILES = debug.o messages.o coercion.o lookup.o OBJDIR = gen/ OBJS = $(addprefix $(OBJDIR),$(OBJFILES)) # Precompiled object files POBJFILES = types.o SyntaxTree.o Node.o Symbol.o SymbolTable.o Scope.o POBJDIR = obj/ POBJS = $(addprefix $(POBJDIR),$(POBJFILES)) IMPORTANT = comp.[hly] *.h *.c *.cc \ Makefile .PHONY: all first clean backup dirs showdeps all: comp # To be executed before the very first build first: dirs # Dependency stuff comp: $(OBJDIR)y.tab.o $(OBJDIR)lex.yy.o $(OBJS) $(POBJS) $(CC) $(LDFLAGS) -o $@ $^ $(LOADLIBS) $(OBJDIR)y.tab.h $(OBJDIR)y.tab.c: comp.y $(YACC) $(YFLAGS) $< -o $(OBJDIR)y.tab.c $(OBJDIR)lex.yy.c: comp.l $(LEX) $(LFLAGS) -o$@ $< clean: rm -f $(OBJDIR){lex.yy.c,y.tab.*,y.output,*.o} *~ comp \ `find . -name core -o -name \*\.bak` backup: tar cfz ../CoCo-`date +'%y%m%d-%H%M'`.tar.gz $(IMPORTANT) dirs: mkdir gen # Show dependencies between .c files showdeps: $(CC) -MM *.c *.cc # Dependency stuff $(OBJDIR)lex.yy.o: $(OBJDIR)lex.yy.c $(OBJDIR)y.tab.h $(OBJDIR)y.tab.o: $(OBJDIR)y.tab.c $(OBJDIR)%.o: %.c $(CC) $(CFLAGS) -c -o $@ $< $(OBJDIR)%.o: %.cc $(CC) $(CFLAGS) -c -o $@ $<