updated parser Makefile to include dependency information

git-svn-id: svn://anubis/fart/trunk@105 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2009-02-16 01:21:28 +00:00
parent 6f2851f279
commit dcbdf4e2ec
2 changed files with 22 additions and 5 deletions

View File

@ -24,4 +24,4 @@ clean:
make -C main clean
make -C shapes clean
make -C util clean
-rm -f $(TARGET) tests
-rm -f $(TARGET)

View File

@ -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)