-
Notifications
You must be signed in to change notification settings - Fork 235
/
Makefile
89 lines (60 loc) · 2.27 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
all: world
FSTAR_HOME ?= $(realpath $(dir $(shell which fstar.exe))/..)
FSTAR_EXE = $(FSTAR_HOME)/bin/fstar.exe
INCLUDE_PATH = $(FSTAR_HOME)/ulib/.cache $(FSTAR_HOME)/ulib/experimental
ifdef KREMLIN_HOME
KRML_EXE = $(KREMLIN_HOME)/krml
endif
world: verify test
FSTAR_OPTIONS = --cache_checked_modules \
--cmi \
--already_cached 'Prims,FStar,LowStar,Steel' \
$(addprefix --include ,$(INCLUDE_PATH)) \
$(OTHERFLAGS)
FSTAR = $(FSTAR_EXE) $(FSTAR_OPTIONS)
ALL_SOURCE_FILES = $(wildcard *.fst *.fsti)
# We need to add some Low* files to the dependency roots, because F* extracts Steel.C null to LowStar null
# since the KReMLin AST does not have a node for null
# TODO: This should be removed, and support for Steel.C null should be directly added to KReMLin instead
SOME_LOWSTAR_FILES = $(FSTAR_HOME)/ulib/LowStar.Monotonic.Buffer.fst $(FSTAR_HOME)/ulib/LowStar.Buffer.fst
.depend: $(ALL_SOURCE_FILES) Makefile
$(FSTAR) --dep full $(ALL_SOURCE_FILES) $(SOME_LOWSTAR_FILES) > $@.tmp
mv $@.tmp $@
depend: .depend
-include .depend
$(ALL_CHECKED_FILES): %.checked:
$(FSTAR) $<
@touch -c $@
verify: $(ALL_CHECKED_FILES)
echo $*
%.fst-in %.fsti-in:
@echo $(FSTAR_OPTIONS)
.PRECIOUS: %.ml
%.ml:
$(FSTAR) $(notdir $(subst .checked,,$<)) --codegen OCaml \
--extract_module $(basename $(notdir $(subst .checked,,$<)))
clean:
-rm -rf *.checked *.krml .depend kremlin.rsp .depend.tmp *.c *.h *.o compile_flags.txt extract
ifdef KREMLIN_HOME
.PRECIOUS: %.krml
%.krml:
$(FSTAR) $(notdir $(subst .checked,,$<)) --codegen Kremlin \
--extract_module $(basename $(notdir $(subst .checked,,$<)))
ALL_MODULE_NAMES=$(basename $(ALL_SOURCE_FILES))
FILTERED_KRML_FILES=$(filter-out FStar_NMST.krml Steel_%.krml,$(ALL_KRML_FILES))
extract: $(FILTERED_KRML_FILES)
$(KRML_EXE) -skip-compilation -skip-makefiles -bundle 'FStar.\*,Steel.\*' $^
touch $@
ALL_C_FILES=$(addsuffix .c,$(ALL_MODULE_NAMES))
$(ALL_C_FILES): %.c: extract
test -f $@
touch $@
ALL_O_FILES=$(subst .c,.o,$(ALL_C_FILES))
$(ALL_O_FILES): %.o: %.c
$(CC) $(CFLAGS) -DKRML_VERIFIED_UINT128 -I $(KREMLIN_HOME)/include -I $(KREMLIN_HOME)/kremlib/dist/minimal -o $@ -c $<
test: $(ALL_O_FILES)
else # no KREMLIN_HOME
test:
echo KReMLin is not installed, skipping test
endif # KREMLIN_HOME
.PHONY: all world verify clean depend test