PROGS=spl1 spl2 pat

# Default target
all: $(PROGS) pat.output

# Dependencies
$(PROGS:=.yy.o): %.yy.o:
$( %.o: %.hpp
$(PROGS:=.yy.o) $( parsetree.hpp

# Rules to generate the final compiled parser programs
$(PROGS): %: %.yy.o
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^

# Generic rule for compiling C++ programs from source
# (Actually, make also defines this by default.)
%.o: %.cpp

# Generic rule for running C++-style flex code generation
# For instance, this will make 'pat.yy.cpp' from 'pat.lpp'.
%.yy.cpp: %.lpp
	flex -o $@ $<

# Generic rule for bison code generation %.ypp
	bison -d $<

%.output: %.ypp
	bison -v $<

.PHONY: clean all
	rm -f *.o *.yy.cpp *.tab.* $(PROGS) $( $(PROGS:=.pdf) $(PROGS:=.output)