forked from FStarLang/karamel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (70 loc) · 2.25 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
# make src/Ast.processed.ml
include $(shell ocamlfind query visitors)/Makefile.preprocess
.PHONY: all minimal clean test pre krmllib install
ifeq ($(OS),Windows_NT)
OCAMLPATH_SEP=;
else
OCAMLPATH_SEP=:
endif
all: minimal krmllib
ifdef FSTAR_HOME
OCAMLPATH:=$(OCAMLPATH)$(OCAMLPATH_SEP)$(FSTAR_HOME)/lib
else
FSTAR_EXE=$(shell which fstar.exe)
ifneq ($(FSTAR_EXE),)
FSTAR_HOME=$(dir $(FSTAR_EXE))/..
OCAMLPATH:=$(OCAMLPATH)$(OCAMLPATH_SEP)$(FSTAR_HOME)/lib
else
# If we are just trying to do a minimal build, we don't need F*.
ifneq ($(MAKECMDGOALS),minimal)
$(error "fstar.exe not found, please install FStar")
endif
endif
endif
export FSTAR_HOME
export OCAMLPATH
minimal: lib/AutoConfig.ml lib/Version.ml
dune build
ln -sf _build/default/src/Karamel.exe krml
krmllib: minimal
$(MAKE) -C krmllib
lib/AutoConfig.ml:
@if [ x"$(PREFIX)" != x ]; then \
echo "let krmllib_dir = \"$(PREFIX)/lib/krml\";;" > $@; \
echo "let runtime_dir = \"$(PREFIX)/lib/krml/runtime\";;" >> $@; \
echo "let include_dir = \"$(PREFIX)/include/\";;" >> $@; \
echo "let misc_dir = \"$(PREFIX)/share/krml/misc/\";;" >> $@; \
else \
echo "let krmllib_dir = \"\";;" > $@; \
echo "let runtime_dir = \"\";;" >> $@; \
echo "let include_dir = \"\";;" >> $@; \
echo "let misc_dir = \"\";;" >> $@; \
fi
.PHONY: src/Version.ml
lib/Version.ml:
@echo "let version = \"$(shell git rev-parse HEAD)\"" > $@ \
clean:
rm -rf krml
$(MAKE) -C src clean
$(MAKE) -C krmllib clean
$(MAKE) -C test clean
test: all
$(MAKE) -C test
# Auto-detection
pre:
@ocamlfind query fstar.lib >/dev/null 2>&1 || \
{ echo "Didn't find fstar.lib via ocamlfind or in FSTAR_HOME (which is: $(FSTAR_HOME)); run $(MAKE) -C $(FSTAR_HOME)"; exit 1; }
install: all
@if [ x"$(PREFIX)" = x ]; then echo "please define PREFIX"; exit 1; fi
mkdir -p $(PREFIX)/bin
cp _build/default/src/Karamel.exe $(PREFIX)/bin/krml
mkdir -p $(PREFIX)/include
cp -r include/* $(PREFIX)/include
mkdir -p $(PREFIX)/lib/krml
cp -r krmllib/* $(PREFIX)/lib/krml
mkdir -p $(PREFIX)/lib/krml/runtime
cp -r runtime/* $(PREFIX)/lib/krml/runtime
mkdir -p $(PREFIX)/share/krml/examples
cp -r test/*.fst $(PREFIX)/share/krml/examples
mkdir -p $(PREFIX)/share/krml/misc
cp -r misc/* $(PREFIX)/share/krml/misc