-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
82 lines (60 loc) · 2.09 KB
/
Makefile
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# the implicit rule for .o:.cpp is
# $(CXX) -c $(CPPFLAGS) $(CFLAGS)
ARCH := UBUNTU
CXX := g++
CPPFLAGS := -Wall -D$(ARCH)
CFLAGS :=
OBJECTS := ast.o aststatements.o astexpressions.o astunits.o asttyping.o astprogram.o memory.o operations.o symboltable.o type.o
SOURCES := $(OBJECTS:.o=.cpp)
TESTS := 1.tok 2.tok 3.tok 4.tok 5.tok
RESULTS := $(TESTS:.tok=.result)
BACKUPDIR := ../toklasbackup
all: toklas ut
toklas: lexer.o parser.o $(OBJECTS)
$(CXX) $(CPPFLAGS) $(CFLAGS) main.cpp lexer.o parser.o $(OBJECTS) -o toklas
parser.o: toklas.tab.c toklas.tab.h
$(CXX) $(CPPFLAGS) $(CFLAGS) -c toklas.tab.c -o parser.o
lexer.o: lex.yy.c toklas.tab.h
$(CXX) $(CPPFLAGS) $(CFLAGS) -c lex.yy.c -o lexer.o
lex.yy.c: toklas.l toklas.tab.h astprogram.h globals.h
flex toklas.l
toklas.tab.h: toklas.tab.c
toklas.tab.c: toklas.y astprogram.h symboltable.h
bison --report=all,itemset --graph=toklas.dot -d toklas.y
ut: $(RESULTS)
%.result: %.tok
toklas -V $*.tok > $*.result
@if [ -e $*.correct ] ; \
then diff $*.result $*.correct > $*.errors && (rm $*.errors && echo $*.tok: passed ) || (echo $*.tok: failed) ; \
else cp $*.result $*.correct && echo $*.tok: replaced ; \
fi
depend:
makedepend $(SOURCES)
graph:
dot -Tpdf toklas.dot -o toklas.pdf
echo "digraph G {" > tmp1.dot
makedepend -f tmp1.dot $(SOURCES)
echo "}" >> tmp1.dot
cat tmp1.dot | sed "s/#.*//g" > tmp2.dot
cat tmp2.dot | sed "s/:\(.*\)/ -> subgraph {\1};/g" > tmp3.dot
cat tmp3.dot | sed "s/\./_/g" > tmp4.dot
cat tmp4.dot | sed "s/_o/_h/g" > tmp5.dot
tred tmp5.dot > incdep.dot
dot -Tpdf incdep.dot -o dependencies.pdf
rm tmp*.dot
clean:
-rm toklas *.o toklas.tab.c toklas.tab.h toklas.output lex.yy.c *.errors *.result outf
backup:
test -a $(BACKUPDIR) || mkdir $(BACKUPDIR)
-rm -f $(BACKUPDIR)/* # could also do this by appending "|| true"
cp *.cpp $(BACKUPDIR)
cp *.h $(BACKUPDIR)
cp *.correct $(BACKUPDIR)
cp *.bak $(BACKUPDIR)
cp *.tok $(BACKUPDIR)
cp *.l $(BACKUPDIR)
cp *.y $(BACKUPDIR)
cp *.txt $(BACKUPDIR)
cp *.odg $(BACKUPDIR)
cp Makefile $(BACKUPDIR)
# DO NOT DELETE THIS LINE -- make depend depends on it