# Default target: make all 3 executables
all: rdcalc rdcalc2 tablecalc

# Dependencies
rdcalc rdcalc2 tablecalc: calc.yy.o
rdcalc.o rdcalc2.o tablecalc.o: calc.h
calc.yy.o: calc.h

# Rules to generate the final compiled parser programs
rdcalc rdcalc2 tablecalc: %: %.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 'calc.yy.cpp' from 'calc.lpp'.
%.yy.cpp: %.lpp
	flex -o $@ $<

.INTERMEDIATE: rdcalc.o rdcalc2.o tablecalc.o calc.yy.o
.PHONY: clean all
clean:
	rm -f *.o *.yy.cpp rdcalc rdcalc2 tablecalc