1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Default target: make all 3 executables
all: bisoncalc rdcalc tablecalc
 
# 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