forked from AbsInt/CompCert
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
297 lines (237 loc) · 9.26 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#######################################################################
# #
# The Compcert verified compiler #
# #
# Xavier Leroy, INRIA Paris-Rocquencourt #
# #
# Copyright Institut National de Recherche en Informatique et en #
# Automatique. All rights reserved. This file is distributed #
# under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 2 of the License, or #
# (at your option) any later version. This file is also distributed #
# under the terms of the INRIA Non-Commercial License Agreement. #
# #
#######################################################################
include Makefile.config
ifeq ($(wildcard $(ARCH)_$(BITSIZE)),)
ARCHDIRS=$(ARCH)
else
ARCHDIRS=$(ARCH)_$(BITSIZE) $(ARCH)
endif
DIRS=lib common $(ARCHDIRS) backend cfrontend driver debug\
flocq/Core flocq/Prop flocq/Calc flocq/Appli exportclight \
cparser cparser/validator
RECDIRS=lib common $(ARCHDIRS) backend cfrontend driver flocq exportclight cparser
COQINCLUDES=$(foreach d, $(RECDIRS), -R $(d) compcert.$(d))
COQC="$(COQBIN)coqc" -q $(COQINCLUDES) $(COQCOPTS)
COQDEP="$(COQBIN)coqdep" $(COQINCLUDES)
COQDOC="$(COQBIN)coqdoc"
COQEXEC="$(COQBIN)coqtop" $(COQINCLUDES) -batch -load-vernac-source
COQCHK="$(COQBIN)coqchk" $(COQINCLUDES)
MENHIR=menhir
CP=cp
VPATH=$(DIRS)
GPATH=$(DIRS)
# Flocq
FLOCQ=\
Fcore_Raux.v Fcore_Zaux.v Fcore_defs.v Fcore_digits.v \
Fcore_float_prop.v Fcore_FIX.v Fcore_FLT.v Fcore_FLX.v \
Fcore_FTZ.v Fcore_generic_fmt.v Fcore_rnd.v Fcore_rnd_ne.v \
Fcore_ulp.v Fcore.v \
Fcalc_bracket.v Fcalc_digits.v Fcalc_div.v Fcalc_ops.v \
Fcalc_round.v Fcalc_sqrt.v \
Fprop_div_sqrt_error.v Fprop_mult_error.v Fprop_plus_error.v \
Fprop_relative.v Fprop_Sterbenz.v \
Fappli_rnd_odd.v Fappli_double_round.v Fappli_IEEE.v Fappli_IEEE_bits.v
# General-purpose libraries (in lib/)
VLIB=Axioms.v Coqlib.v Intv.v Maps.v Heaps.v Lattice.v Ordered.v \
Iteration.v Integers.v Archi.v Fappli_IEEE_extra.v Floats.v \
Parmov.v UnionFind.v Wfsimpl.v \
Postorder.v FSetAVLplus.v IntvSets.v Decidableplus.v BoolEqual.v
# Parts common to the front-ends and the back-end (in common/)
COMMON=Errors.v AST.v Linking.v \
Events.v Globalenvs.v Memdata.v Memtype.v Memory.v \
Memimpl.v \
Values.v Smallstep.v Behaviors.v Switch.v Determinism.v Unityping.v \
Separation.v
# Back-end modules (in backend/, $(ARCH)/)
BACKEND=\
Cminor.v Op.v CminorSel.v \
SelectOp.v SelectDiv.v SplitLong.v SelectLong.v Selection.v \
SelectOpproof.v SelectDivproof.v SplitLongproof.v \
SelectLongproof.v Selectionproof.v \
Registers.v RTL.v \
RTLgen.v RTLgenspec.v RTLgenproof.v \
Tailcall.v Tailcallproof.v \
Inlining.v Inliningspec.v Inliningproof.v \
Renumber.v Renumberproof.v \
RTLtyping.v \
Kildall.v Liveness.v \
ValueDomain.v ValueAOp.v ValueAnalysis.v \
ConstpropOp.v Constprop.v ConstpropOpproof.v Constpropproof.v \
CSEdomain.v CombineOp.v CSE.v CombineOpproof.v CSEproof.v \
NeedDomain.v NeedOp.v Deadcode.v Deadcodeproof.v \
Unusedglob.v Unusedglobproof.v \
Unusedglobproofimpl.v \
Machregs.v Locations.v Conventions1.v Conventions.v LTL.v \
Allocation.v Allocproof.v \
Tunneling.v Tunnelingproof.v \
Linear.v Lineartyping.v \
Linear2.v \
Linearize.v Linearizeproof.v \
CleanupLabels.v CleanupLabelsproof.v \
Debugvar.v Debugvarproof.v \
Mach.v \
EraseArgs.v \
Bounds.v Stacklayout.v Stacking.v Stackingproof.v \
Asm.v Asmgen.v Asmgenproof0.v Asmgenproof1.v Asmgenproof.v
# C front-end modules (in cfrontend/)
CFRONTEND=Ctypes.v Cop.v Csyntax.v Csem.v Ctyping.v Cstrategy.v Cexec.v \
Cexecimpl.v \
Initializers.v Initializersproof.v \
SimplExpr.v SimplExprspec.v SimplExprproof.v \
Clight.v ClightBigstep.v SimplLocals.v SimplLocalsproof.v \
Cshmgen.v Cshmgenproof.v \
Csharpminor.v Cminorgen.v Cminorgenproof.v
# LR(1) parser validator
PARSERVALIDATOR=Alphabet.v Interpreter_complete.v Interpreter.v \
Validator_complete.v Automaton.v Interpreter_correct.v Main.v \
Validator_safe.v Grammar.v Interpreter_safe.v Tuples.v
# Parser
PARSER=Cabs.v Parser.v
# Putting everything together (in driver/)
DRIVER=Compopts.v Compiler.v Complements.v Compilerimpl.v
# All source files
FILES=$(VLIB) $(COMMON) $(BACKEND) $(CFRONTEND) $(DRIVER) $(FLOCQ) \
$(PARSERVALIDATOR) $(PARSER)
# Generated source files
GENERATED=\
$(ARCH)/ConstpropOp.v $(ARCH)/SelectOp.v $(ARCH)/SelectLong.v \
backend/SelectDiv.v backend/SplitLong.v \
cparser/Parser.v
all:
@test -f .depend || $(MAKE) depend
$(MAKE) proof
$(MAKE) extraction
$(MAKE) ccomp
ifeq ($(HAS_RUNTIME_LIB),true)
$(MAKE) runtime
endif
ifeq ($(CLIGHTGEN),true)
$(MAKE) clightgen
endif
proof: $(FILES:.v=.vo)
# Turn off some warnings for compiling Flocq
flocq/%.vo: COQCOPTS+=-w -deprecated-implicit-arguments
extraction: extraction/STAMP
extraction/STAMP: $(FILES:.v=.vo) extraction/extraction.v $(ARCH)/extractionMachdep.v
rm -f extraction/*.ml extraction/*.mli
$(COQEXEC) extraction/extraction.v
touch extraction/STAMP
.depend.extr: extraction/STAMP tools/modorder driver/Version.ml
$(MAKE) -f Makefile.extr depend
ccomp: .depend.extr compcert.ini driver/Version.ml FORCE
$(MAKE) -f Makefile.extr ccomp
ccomp.byte: .depend.extr compcert.ini driver/Version.ml FORCE
$(MAKE) -f Makefile.extr ccomp.byte
clightgen: .depend.extr compcert.ini exportclight/Clightdefs.vo driver/Version.ml FORCE
$(MAKE) -f Makefile.extr clightgen
clightgen.byte: .depend.extr compcert.ini exportclight/Clightdefs.vo driver/Version.ml FORCE
$(MAKE) -f Makefile.extr clightgen.byte
runtime:
$(MAKE) -C runtime
FORCE:
.PHONY: proof extraction runtime FORCE
documentation: doc/coq2html $(FILES)
mkdir -p doc/html
rm -f doc/html/*.html
doc/coq2html -o 'doc/html/%.html' doc/*.glob \
$(filter-out doc/coq2html cparser/Parser.v, $^)
cp doc/coq2html.css doc/coq2html.js doc/html/
doc/coq2html: doc/coq2html.ml
ocamlopt -w +a-29 -o doc/coq2html str.cmxa doc/coq2html.ml
doc/coq2html.ml: doc/coq2html.mll
ocamllex -q doc/coq2html.mll
tools/ndfun: tools/ndfun.ml
ocamlopt -o tools/ndfun str.cmxa tools/ndfun.ml
tools/modorder: tools/modorder.ml
ocamlopt -o tools/modorder str.cmxa tools/modorder.ml
latexdoc:
cd doc; $(COQDOC) --latex -o doc/doc.tex -g $(FILES)
%.vo: %.v
@rm -f doc/$(*F).glob
@echo "COQC $*.v"
@$(COQC) -dump-glob doc/$(*F).glob $*.v
%.v: %.vp tools/ndfun
@rm -f $*.v
@echo "Preprocessing $*.vp"
@tools/ndfun $*.vp > $*.v || { rm -f $*.v; exit 2; }
@chmod -w $*.v
compcert.ini: Makefile.config
(echo "stdlib_path=$(LIBDIR)"; \
echo "prepro=$(CPREPRO)"; \
echo "linker=$(CLINKER)"; \
echo "asm=$(CASM)"; \
echo "prepro_options=$(CPREPRO_OPTIONS)";\
echo "asm_options=$(CASM_OPTIONS)";\
echo "linker_options=$(CLINKER_OPTIONS)";\
echo "arch=$(ARCH)"; \
echo "model=$(MODEL)"; \
echo "abi=$(ABI)"; \
echo "endianness=$(ENDIANNESS)"; \
echo "system=$(SYSTEM)"; \
echo "has_runtime_lib=$(HAS_RUNTIME_LIB)"; \
echo "has_standard_headers=$(HAS_STANDARD_HEADERS)"; \
echo "asm_supports_cfi=$(ASM_SUPPORTS_CFI)"; \
echo "struct_passing_style=$(STRUCT_PASSING)"; \
echo "struct_return_style=$(STRUCT_RETURN)"; \
echo "response_file_style=$(RESPONSEFILE)";) \
> compcert.ini
driver/Version.ml: VERSION
cat VERSION \
| sed -e 's|\(.*\)=\(.*\)|let \1 = \"\2\"|g' \
>driver/Version.ml
cparser/Parser.v: cparser/Parser.vy
$(MENHIR) --coq cparser/Parser.vy
depend: $(GENERATED) depend1
depend1: $(FILES) exportclight/Clightdefs.v
@echo "Analyzing Coq dependencies"
@$(COQDEP) $^ > .depend
install:
install -d $(BINDIR)
install -m 0755 ./ccomp $(BINDIR)
install -d $(SHAREDIR)
install -m 0644 ./compcert.ini $(SHAREDIR)
install -d $(MANDIR)/man1
install -m 0644 ./doc/ccomp.1 $(MANDIR)/man1
$(MAKE) -C runtime install
ifeq ($(CLIGHTGEN),true)
install -m 0755 ./clightgen $(BINDIR)
endif
clean:
rm -f $(patsubst %, %/*.vo, $(DIRS))
rm -f $(patsubst %, %/.*.aux, $(DIRS))
rm -rf doc/html doc/*.glob
rm -f doc/coq2html.ml doc/coq2html doc/*.cm? doc/*.o
rm -f driver/Version.ml
rm -f compcert.ini
rm -f extraction/STAMP extraction/*.ml extraction/*.mli .depend.extr
rm -f tools/ndfun tools/modorder tools/*.cm? tools/*.o
rm -f $(GENERATED) .depend
$(MAKE) -f Makefile.extr clean
$(MAKE) -C runtime clean
$(MAKE) -C test clean
distclean:
$(MAKE) clean
rm -f Makefile.config
check-admitted: $(FILES)
@grep -w 'admit\|Admitted\|ADMITTED' $^ || echo "Nothing admitted."
# Problems with coqchk (coq 8.6):
# Integers.Int.Z_mod_modulus_range takes forever to check
# compcert.backend.SelectDivproof.divs_mul_shift_2 takes forever to check
check-proof: $(FILES)
$(COQCHK) -admit Integers -admit SelectDivproof Complements
print-includes:
@echo $(COQINCLUDES)
-include .depend
FORCE: