46 lines
838 B
Makefile
46 lines
838 B
Makefile
|
|
FLEX := flex
|
|
BISON := bison
|
|
|
|
PARSER := parser
|
|
|
|
COBJS := lex.yy.o
|
|
CXXOBJS := $(PARSER).tab.o
|
|
OBJS := $(COBJS) $(CXXOBJS)
|
|
|
|
all: $(OBJS)
|
|
|
|
%.o: %.c
|
|
$(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $<
|
|
|
|
%.o: %.cc
|
|
$(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $<
|
|
|
|
$(PARSER).tab.cc $(PARSER).tab.hh: $(PARSER).yy
|
|
$(BISON) -d $<
|
|
|
|
lex.yy.o: lex.yy.c
|
|
|
|
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 *.dep
|
|
|
|
# Include dependency files
|
|
include $(OBJS:.o=.dep)
|