# Default target: run bcalc and show the pdf
show: bcalc
./bcalc
dot -Tpdf bcalc.dot > bcalc.pdf
evince bcalc.pdf &> /dev/null &
CXX = g++
# Dependencies
bcalc.yy.o: %.yy.o: %.tab.hpp
bcalc.tab.o: %.o: %.hpp
bcalc.yy.o bcalc.tab.o: parsetree.hpp
# Rules to generate the final compiled parser programs
bcalc: %: %.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 $<
.PHONY: clean show
clean:
rm -f *.o *.yy.cpp *.tab.* bcalc bcalc.dot bcalc.pdf