## SI 413 Fall 2011
## Makefile for Lab 4

# Default target: makes both programs
all: ex1 ex2

# Dependencies
ex1.yy.o ex2.yy.o: %.yy.o: %.tab.hpp
ex1.tab.o ex2.tab.o: %.o: %.hpp

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

# Generic rule for compiling C++ programs from source
# (Actually, make also defines this by default.)
%.o: %.cpp
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $<

# 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
%.tab.cpp %.tab.hpp: %.ypp
	bison -d $<

# Get the CFSMs from bison
%.output: %.ypp
	bison -v $<

.PHONY: clean all
clean:
	rm -f *.o *.yy.cpp *.tab.* ex1 ex2 *.output