forked from mit-plv/fiat-crypto
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.standalone
149 lines (130 loc) · 7.4 KB
/
Makefile.standalone
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
# IMPORTANT: This file MUST NOT introduce dependencies of the .ml/.hs
# files on .v files, so that we can compile them by invoking this
# makefile directly even when Coq is not available
SELF_MAKEFILE_STANDALONE := $(lastword $(MAKEFILE_LIST))
include Makefile.config
GHC?=ghc
GHCFLAGS?= # -XStrict
# in case we didn't include Makefile.coq
OCAMLFIND?=ocamlfind
OCAMLOPT?="$(OCAMLFIND)" ocamlopt
OCAMLOPTP?="$(OCAMLFIND)" ocamloptp
ifneq ($(WITH_PERF),1)
CAMLOPT_PERF ?= $(OCAMLOPT)
CAMLOPT_PERF_SHOW:=OCAMLOPT
else
CAMLOPT_PERF ?= $(OCAMLOPTP)
CAMLOPT_PERF_SHOW:=OCAMLOPTP
endif
CAMLEXTRAFLAGS ?=
STANDALONE_CAMLFLAGS ?= -package unix -w -20 -g $(CAMLEXTRAFLAGS)
PACKAGE ?= standalone.tar.gz
PACKAGE_CMD ?= tar -czvf
PACKAGE_CMD_FUNC ?= $(PACKAGE_CMD) $(1) $(2)
MKTEMP_D ?= etc/ci/mktemp_d.sh
ENSURE_STACK_LIMIT := . etc/ensure_stack_limit.sh || true
.PHONY: \
perf-standalone \
standalone-unified install-standalone-unified install-standalone-unified \
standalone-separate install-standalone-separate uninstall-standalone-separate \
standalone install-standalone uninstall-standalone \
standalone-unified-ocaml install-standalone-unified-ocaml uninstall-standalone-unified-ocaml \
standalone-separate-ocaml install-standalone-separate-ocaml uninstall-standalone-separate-ocaml \
standalone-ocaml install-standalone-ocaml uninstall-standalone-ocaml \
standalone-unified-haskell install-standalone-unified-haskell uninstall-standalone-unified-haskell \
standalone-separate-haskell install-standalone-separate-haskell uninstall-standalone-separate-haskell \
standalone-haskell install-standalone-haskell uninstall-standalone-haskell \
package-standalone package-standalone-ocaml package-standalone-haskell \
package-standalone-unified package-standalone-unified-ocaml package-standalone-unified-haskell \
package-standalone-separate package-standalone-separate-ocaml package-standalone-separate-haskell \
#
# pass -w -20 to disable the unused argument warning
# unix package needed for Unix.gettimeofday for the perf_* binaries
$(STANDALONE_OCAML:%=src/ExtractionOCaml/%.cmi) : %.cmi : %.ml
$(SHOW)'$(CAMLOPT_PERF_SHOW) $*.mli'
$(HIDE)$(ENSURE_STACK_LIMIT); \
$(TIMER) $(CAMLOPT_PERF) $(STANDALONE_CAMLFLAGS) $*.mli
$(STANDALONE_OCAML:%=src/ExtractionOCaml/%) : % : %.ml %.cmi
$(SHOW)'$(CAMLOPT_PERF_SHOW) $< -o $@'
$(HIDE)$(ENSURE_STACK_LIMIT); \
$(TIMER) $(CAMLOPT_PERF) $(STANDALONE_CAMLFLAGS) -linkpkg -I src/ExtractionOCaml/ -o $@ $<
$(STANDALONE_HASKELL:%=src/ExtractionHaskell/%) : % : %.hs
$(SHOW)'GHC $< -o $@'
$(HIDE)$(TIMER) $(GHC) $(GHCFLAGS) -o $@ $<
standalone: standalone-haskell standalone-ocaml
standalone-unified: standalone-unified-haskell standalone-unified-ocaml
standalone-separate: standalone-separate-haskell standalone-separate-ocaml
perf-standalone: $(PERF_STANDALONE:%=src/ExtractionOCaml/%)
standalone-ocaml: standalone-unified-ocaml standalone-separate-ocaml
standalone-unified-ocaml: $(UNIFIED_STANDALONE_OCAML:%=src/ExtractionOCaml/%)
standalone-separate-ocaml: $(SEPARATE_STANDALONE_OCAML:%=src/ExtractionOCaml/%)
standalone-haskell: standalone-unified-haskell standalone-separate-haskell
standalone-unified-haskell: $(UNIFIED_STANDALONE_HASKELL:%=src/ExtractionHaskell/%)
standalone-separate-haskell: $(SEPARATE_STANDALONE_HASKELL:%=src/ExtractionHaskell/%)
# FIXME HERE
uninstall-standalone-ocaml: FILESTOINSTALL=$(OCAML_BINARIES)
uninstall-standalone-unified-ocaml: FILESTOINSTALL=$(UNIFIED_OCAML_BINARIES)
uninstall-standalone-separate-ocaml: FILESTOINSTALL=$(SEPARATE_OCAML_BINARIES)
uninstall-standalone-haskell: FILESTOINSTALL=$(HASKELL_BINARIES)
uninstall-standalone-unified-haskell: FILESTOINSTALL=$(UNIFIED_HASKELL_BINARIES)
uninstall-standalone-separate-haskell: FILESTOINSTALL=$(SEPARATE_HASKELL_BINARIES)
ifeq ($(SKIP_BEDROCK2),1)
install-standalone-ocaml: FILESTOINSTALL=$(OCAML_BINARIES)
install-standalone-unified-ocaml: FILESTOINSTALL=$(UNIFIED_OCAML_BINARIES)
install-standalone-separate-ocaml: FILESTOINSTALL=$(SEPARATE_OCAML_BINARIES)
install-standalone-haskell: FILESTOINSTALL=$(HASKELL_BINARIES)
install-standalone-unified-haskell: FILESTOINSTALL=$(UNIFIED_HASKELL_BINARIES)
install-standalone-separate-haskell: FILESTOINSTALL=$(SEPARATE_HASKELL_BINARIES)
install-standalone-ocaml install-standalone-unified-ocaml install-standalone-separate-ocaml install-standalone-haskell install-standalone-unified-haskell install-standalone-separate-haskell:
$(HIDE)code=0; for f in $(FILESTOINSTALL); do\
if ! [ -f "$$f" ]; then >&2 echo $$f does not exist; code=1; fi \
done; exit $$code
$(HIDE)for f in $(FILESTOINSTALL); do\
install -d "$(BINDIR)/" &&\
install -m 0755 "$$f" "$(BINDIR)/" &&\
echo INSTALL "$$f" "$(BINDIR)/";\
done
else
install-standalone-ocaml: FILESTOINSTALL=$(WITH_BEDROCK2_OCAML_BINARIES)
install-standalone-unified-ocaml: FILESTOINSTALL=$(WITH_BEDROCK2_UNIFIED_OCAML_BINARIES)
install-standalone-separate-ocaml: FILESTOINSTALL=$(WITH_BEDROCK2_SEPARATE_OCAML_BINARIES)
install-standalone-haskell: FILESTOINSTALL=$(WITH_BEDROCK2_HASKELL_BINARIES)
install-standalone-unified-haskell: FILESTOINSTALL=$(WITH_BEDROCK2_UNIFIED_HASKELL_BINARIES)
install-standalone-separate-haskell: FILESTOINSTALL=$(WITH_BEDROCK2_SEPARATE_HASKELL_BINARIES)
install-standalone-ocaml install-standalone-unified-ocaml install-standalone-separate-ocaml install-standalone-haskell install-standalone-unified-haskell install-standalone-separate-haskell:
$(HIDE)code=0; for f in $(FILESTOINSTALL); do\
if ! [ -f "$$f" ]; then >&2 echo $$f does not exist; code=1; fi \
done; exit $$code
$(HIDE)for f in $(FILESTOINSTALL); do\
fdir="$$(dirname "$$f")" &&\
fname="$$(basename "$$f")" &&\
df="$${fname#with_bedrock2_}" &&\
install -d "$(BINDIR)/" &&\
install -m 0755 "$$f" "$(BINDIR)/$$df" &&\
echo INSTALL "$$f" "$(BINDIR)/$$df";\
done
endif
uninstall-standalone-ocaml uninstall-standalone-unified-ocaml uninstall-standalone-separate-ocaml uninstall-standalone-haskell uninstall-standalone-unified-haskell uninstall-standalone-separate-haskell:
$(HIDE)for f in $(FILESTOINSTALL); do \
instf="$(BINDIR)/`basename $$f`" &&\
rm -f "$$instf" &&\
echo RM "$$instf"; \
done
install-standalone: install-standalone-ocaml # install-standalone-haskell
install-standalone-unified: install-standalone-unified-ocaml # install-standalone-unified-haskell
install-standalone-separate: install-standalone-separate-ocaml # install-standalone-separate-haskell
uninstall-standalone: uninstall-standalone-ocaml # uninstall-standalone-haskell
uninstall-standalone-unified: uninstall-standalone-unified-ocaml # uninstall-standalone-unified-haskell
uninstall-standalone-separate: uninstall-standalone-separate-ocaml # uninstall-standalone-separate-haskell
package-standalone: package-standalone-ocaml # package-standalone-haskell
package-standalone-unified: package-standalone-unified-ocaml # package-standalone-unified-haskell
package-standalone-separate: package-standalone-separate-ocaml # package-standalone-separate-haskell
package-standalone-ocaml package-standalone-unified-ocaml package-standalone-separate-ocaml package-standalone-haskell package-standalone-unified-haskell package-standalone-separate-haskell : package-standalone-% :
$(SHOW)'PACKAGE STANDALONE $*'
$(HIDE)rm -f "$(PACKAGE)"
+$(HIDE)standalonedir="$$(TMPDIR="$$(pwd)" $(MKTEMP_D))"; \
$(MAKE) -f $(SELF_MAKEFILE_STANDALONE) install-standalone-$* BINDIR="$$standalonedir" && \
cd "$$standalonedir" && \
$(call PACKAGE_CMD_FUNC,../$(PACKAGE),./*) && \
cd ../ && \
rm -rf "$$standalonedir"