-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
224 lines (187 loc) · 5.03 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
CC = gcc
LEX = flex
YACC = bison
DEBUG = true
O = .o
EXE =
TEMPDIR = /tmp
ifeq ($(DEBUG), true)
CFLAGS = -O0 -g -W -Wall
else
CFLAGS = -O3 -W -Wall
endif
M1_O_FILES = \
src/m1parser$(O) \
src/m1lexer$(O) \
src/ast$(O) \
src/symtab$(O) \
src/semcheck$(O) \
src/stack$(O) \
src/decl$(O) \
src/eval$(O) \
src/instr$(O) \
src/gencode$(O) \
src/main$(O) \
m1$(EXE): $(M1_O_FILES)
$(CC) -pg -fprofile-arcs -ftest-coverage -I$(@D) -o m1$(EXE) $(M1_O_FILES)
src/m1lexer$(O): src/m1lexer.c
$(CC) $(CFLAGS) -I$(@D) -o $@ -c src/m1lexer.c
src/m1parser$(O): src/m1parser.c
$(CC) $(CFLAGS) -I$(@D) -o $@ -c src/m1parser.c
src/m1parser.c: src/m1.y src/m1lexer.c
$(YACC) --output=src/m1parser.c src/m1.y
src/m1lexer.c: src/m1.l
$(LEX) --header-file=src/m1lexer.h --outfile=src/m1lexer.c src/m1.l
src/ast$(O): src/ast.c src/ast.h
$(CC) $(CFLAGS) -I$(@D) -o $@ -c src/ast.c
src/eval$(O): src/eval.c src/eval.h
$(CC) $(CFLAGS) -I$(@D) -o $@ -c src/eval.c
src/symtab$(O): src/symtab.c src/symtab.h
$(CC) $(CFLAGS) -I$(@D) -o $@ -c src/symtab.c
src/instr$(O): src/instr.c src/instr.h
$(CC) $(CFLAGS) -I$(@D) -o $@ -c src/instr.c
src/gencode$(O): src/gencode.c src/gencode.h
$(CC) $(CFLAGS) -I$(@D) -o $@ -c src/gencode.c
src/semcheck$(O): src/semcheck.c src/semcheck.h
$(CC) $(CFLAGS) -I$(@D) -o $@ -c src/semcheck.c
src/stack$(O): src/stack.c src/stack.h
$(CC) $(CFLAGS) -I$(@D) -o $@ -c src/stack.c
src/main$(O): src/m1parser.h src/main.c
$(CC) $(CFLAGS) -I$(@D) -o $@ -c src/main.c
src/decl$(O): src/decl.c src/decl.h
$(CC) $(CFLAGS) -I$(@D) -o $@ -c src/decl.c
test-v: m1$(EXE)
prove -r -v --ext .m1 --exec ./run_m1.sh t/
test: m1$(EXE)
prove -r --ext .m1 --exec ./run_m1.sh t/
clean:
$(RM) -rf src/m1parser.* \
src/m1lexer.* \
src/*$(O) \
./m1$(EXE) \
t/*.m0*
# For checking with splint see also
# http://trac.parrot.org/parrot/wiki/splint
# Splint: http://splint.org
SPLINT = splint
# Temp directory for splint. Add +keep to splintflags if you want work files
# kept in there after completion.
SPLINT_TMP = $(TEMPDIR)/splint
# Splint flags: http://splint.org/manual/html/appB.html
# The dashes in the names don't make any difference to Splint, but I've
# made them match how they are in the manual. Otherwise, you might be
# looking for "declundef", except that it's "decl-undef" in the docs.
SPLINTFLAGS_BASE = \
+weak \
+hints \
\
+indentspaces 4 \
+locindentspaces 4 \
+linelen 999 \
+bugslimit 1000 \
-message-stream-stdout \
+showdeephistory \
+show-func \
+show-column \
-tmpdir $(SPLINT_TMP) \
\
+posix-lib \
-skip-posix-headers \
\
+ansi89-limits \
+num-struct-fields 255 \
how-summary \
+show-scan \
+time-dist \
\
+cpp-names \
+ansi-reserved \
+ansi-reserved-internal \
-iso-reserved \
-iso-reserved-internal \
-include-nest 10 \
SPLINTFLAGS_NULL_DEREFERENCES = \
+null \
+nullret \
SPLINTFLAGS_USE_BEFORE_DEFINITION = \
+usedef \
+incondefs \
+functionderef \
SPLINTFLAGS_TYPE = \
+string-literal-too-long \
+string-literal-no-room \
+string-literal-no-room-final-null \
+string-literal-smaller \
+enum-members \
\
-pred-bool \
-pred-bool-ptr \
-pred-bool-int \
+pred-bool-others \
+pred-assign \
+ptrnegate \
-zero-ptr \
\
+charunsignedchar \
+char-index \
+char-int \
\
+format-code \
+format-type \
\
+ignore-signs \
+long-unsigned-unsigned-integral \
SPLINTFLAGS_MEMORY_MANAGEMENT = \
SPLINTFLAGS_SHARING = \
SPLINTFLAGS_FUNCTION_INTERFACE = \
# Macro safety checks
SPLINTFLAGS_MACRO = \
+macro-assign \
+macro-empty \
+macro-parens \
+macro-redef \
+macro-stmt \
+macro-unrecog \
SPLINTFLAGS_NAMING = \
SPLINTFLAGS_CONTROL_FLOW = \
+eval-order \
+eval-order-uncon \
SPLINTFLAGS_MEMORY_BOUNDS = \
SPLINTFLAGS_COMPLETENESS = \
SPLINTFLAGS_MISCELLANEOUS = \
# Other options we'd like to add back
# +initallelements : Right now, the *.ops files don't initialize all
# values of the arrays
# +casebreak: Auto-generated ops have way too case fallthrus right now
# +fcnuse: We have many functions that are defined but not used, but they
# should get hidden or ifdeffed
# +redef, +redecl: Ops currently have tons of redefinitions
# added to splint target to simplify experimentation,
# example: make SPLINTFLAGS_TEST='-posixstrictlib +posixlib' splint
SPLINTFLAGS_TEST =
SPLINTFLAGS = \
$(SPLINTFLAGS_BASE) \
$(SPLINTFLAGS_NULL_DEREFERENCES) \
$(SPLINTFLAGS_USE_BEFORE_DEFINITION) \
$(SPLINTFLAGS_TYPE) \
$(SPLINTFLAGS_MEMORY_MANAGEMENT) \
$(SPLINTFLAGS_SHARING) \
$(SPLINTFLAGS_FUNCTION_INTERFACE) \
$(SPLINTFLAGS_MACRO) \
$(SPLINTFLAGS_NAMING) \
$(SPLINTFLAGS_CONTROL_FLOW) \
$(SPLINTFLAGS_MEMORY_BOUNDS) \
$(SPLINTFLAGS_COMPLETENESS) \
$(SPLINTFLAGS_MISCELLANEOUS) \
SPLINT_SOURCE = \
$$(find src/*.c -type f | \
sort)
# "splint" is the less-thorough splint target. For cage cleaning work,
# you'll probably want to specify SPLINT_SOURCE rather than work on the
# entire tree, like so:
# make splint SPLINT_SOURCE='src/*.c'
splint :
$(SPLINT) "-I./src" $(SPLINTFLAGS) \
+partial -DNDEBUG \
$(SPLINT_SOURCE) \
| grep -v 'Source code error generation point'