From dcbdf4e2ec1631d0427af890631898f4a31d2645 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 16 Feb 2009 01:21:28 +0000 Subject: [PATCH] updated parser Makefile to include dependency information git-svn-id: svn://anubis/fart/trunk@105 7f9b0f55-74a9-4bce-be96-3c2cd072584d --- Makefile | 2 +- parser/Makefile | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d493b13..1c86195 100644 --- a/Makefile +++ b/Makefile @@ -24,4 +24,4 @@ clean: make -C main clean make -C shapes clean make -C util clean - -rm -f $(TARGET) tests + -rm -f $(TARGET) diff --git a/parser/Makefile b/parser/Makefile index 2288a47..bd897a5 100644 --- a/parser/Makefile +++ b/parser/Makefile @@ -6,14 +6,15 @@ PARSER := parser COBJS := lex.yy.o CXXOBJS := $(PARSER).tab.o +OBJS := $(COBJS) $(CXXOBJS) -all: $(COBJS) $(CXXOBJS) +all: $(OBJS) %.o: %.c - $(CC) -c -o $@ $(CPPFLAGS) $< + $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $< %.o: %.cc - $(CXX) -c -o $@ $(CPPFLAGS) $< + $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $< $(PARSER).tab.cc $(PARSER).tab.hh: $(PARSER).yy $(BISON) -d $< @@ -24,5 +25,21 @@ lex.yy.c: $(PARSER).tab.hh lex.yy.c: $(PARSER).lex $(FLEX) $< +# Make dependency files +%.dep: %.c + @set -e; rm -f $@; \ + $(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +%.dep: %.cc + @set -e; rm -f $@; \ + $(CXX) -MM $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + clean: - -rm -f lex.yy.c $(PARSER).tab.cc $(PARSER).tab.hh *~ *.o + -rm -f lex.yy.c $(PARSER).tab.cc $(PARSER).tab.hh *~ *.o *.dep + +# Include dependency files +include $(OBJS:.o=.dep)