# enable extra compiler warnings
CXXFLAGS = -Wall -Wextra -Wno-unused-function
EXES = bisoncalc rdcalc tablecalc
# Default target: make all executables
all: $(EXES)
# Dependencies
# Generic rule for running bison to generate scanner code.
# For instance, this will make bisoncalc.tab.cpp and bisoncalc.tab.hpp
%.tab.cpp %.tab.hpp: %.ypp
bison -d $<
# 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 $@ $<
# Dependencies
bisoncalc: calc-scanner.o
rdcalc tablecalc: flexcalc.yy.o
calc-scanner.o flexcalc.yy.o bisoncalc.o rdcalc.o tablecalc.o: bisoncalc.tab.hpp
rdcalc tablecalc: %: %.o
bisoncalc: %: %.tab.o
# Rules to generate the final compiled parser programs
bisoncalc rdcalc tablecalc:
$(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 $<
.INTERMEDIATE: rdcalc.o rdcalc2.o tablecalc.o calc.yy.o
.PHONY: clean all
clean:
rm -f *.o *.yy.cpp *.tab.cpp *.tab.hpp bisoncalc rdcalc tablecalc