forked from mit-plv/fiat-crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.standalone
238 lines (210 loc) · 12 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
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
# 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
OCAMLC?="$(OCAMLFIND)" ocamlc
OCAMLOPTP?="$(OCAMLFIND)" ocamloptp
ifneq ($(WITH_PERF),1)
CAMLOPT_PERF ?= $(OCAMLOPT)
CAMLOPT_PERF_SHOW:=OCAMLOPT
else
CAMLOPT_PERF ?= $(OCAMLOPTP)
CAMLOPT_PERF_SHOW:=OCAMLOPTP
endif
CAMLEXTRAFLAGS ?=
JS_OF_OCAML ?= js_of_ocaml
WASM_OF_OCAML ?= wasm_of_ocaml
STANDALONE_CAMLFLAGS ?= -package unix -w -20 -g $(CAMLEXTRAFLAGS)
STANDALONE_JS_CAMLFLAGS ?= -package js_of_ocaml $(STANDALONE_CAMLFLAGS)
JS_OF_OCAML_EXTRAFLAGS ?=
JS_OF_OCAML_FLAGS ?= --source-map --no-inline --enable=effects $(JS_OF_OCAML_EXTRAFLAGS)
WASM_OF_OCAML_EXTRAFLAGS ?=
WASM_OF_OCAML_FLAGS ?= --source-map --no-inline $(WASM_OF_OCAML_EXTRAFLAGS)
PACKAGE ?= standalone.tar.gz
PACKAGE_CMD ?= tar -czvf
PACKAGE_CMD_FUNC ?= $(PACKAGE_CMD) $(1) $(2)
MKTEMP_D ?= etc/ci/mktemp_d.sh
GZIP ?= gzip
GZIP_KEEP_FLAGS ?= -k
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 \
standalone-js-of-ocaml install-standalone-js-of-ocaml uninstall-standalone-js-of-ocaml \
standalone-wasm-of-ocaml install-standalone-wasm-of-ocaml uninstall-standalone-wasm-of-ocaml \
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_JS_OF_OCAML:%=src/ExtractionJsOfOCaml/%.cmi) : %.cmi : %.ml
$(SHOW)'OCAMLC $*.mli'
$(HIDE)$(ENSURE_STACK_LIMIT); \
$(TIMER) $(OCAMLC) $(STANDALONE_JS_CAMLFLAGS) $*.mli
$(STANDALONE_JS_OF_OCAML:%=src/ExtractionJsOfOCaml/%.byte) : %.byte : %.ml %.cmi
$(SHOW)'OCAMLC $< -o $@'
$(HIDE)$(ENSURE_STACK_LIMIT); \
$(TIMER) $(OCAMLC) $(STANDALONE_JS_CAMLFLAGS) -linkpkg -I src/ExtractionJsOfOCaml/ -o $@ $<
$(STANDALONE_JS_OF_OCAML:%=src/ExtractionJsOfOCaml/%.js) : %.js : %.byte
$(SHOW)'JS_OF_OCAML $<'
$(HIDE)$(ENSURE_STACK_LIMIT); \
$(TIMER) $(JS_OF_OCAML) $(JS_OF_OCAML_FLAGS) $<
$(STANDALONE_JS_OF_OCAML:%=src/ExtractionJsOfOCaml/%.wasm) : %.wasm : %.byte
$(SHOW)'WASM_OF_OCAML $<'
$(HIDE)$(ENSURE_STACK_LIMIT); \
$(TIMER) $(WASM_OF_OCAML) $(WASM_OF_OCAML_FLAGS) $<
$(STANDALONE_JS_OF_OCAML:%=src/ExtractionJsOfOCaml/%.wat.gz) : %.wat.gz : %.wasm
$(SHOW)'GZIP $*'
$(HIDE)$(TIMER) $(GZIP) $(GZIP_KEEP_FLAGS) $*.wat
$(STANDALONE_HASKELL:%=src/ExtractionHaskell/%) : % : %.hs
$(SHOW)'GHC $< -o $@'
$(HIDE)$(TIMER) $(GHC) $(GHCFLAGS) -o $@ $<
standalone: standalone-haskell standalone-ocaml standalone-js-of-ocaml
standalone-unified: standalone-unified-haskell standalone-unified-ocaml standalone-js-of-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/%)
standalone-js-of-ocaml: $(STANDALONE_JS_OF_OCAML:%=src/ExtractionJsOfOCaml/%.js)
standalone-wasm-of-ocaml: $(STANDALONE_WASM_OF_OCAML:%=src/ExtractionJsOfOCaml/%.wasm) $(STANDALONE_WASM_OF_OCAML:%=src/ExtractionJsOfOCaml/%.wat.gz)
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)
uninstall-standalone-js-of-ocaml: FILESTOINSTALL=$(JS_OF_OCAML_FILES)
uninstall-standalone-wasm-of-ocaml: FILESTOINSTALL=$(WASM_OF_OCAML_FILES)
install-standalone-ocaml install-standalone-unified-ocaml install-standalone-separate-ocaml install-standalone-haskell install-standalone-unified-haskell install-standalone-separate-haskell: PERMS=0755
install-standalone-js-of-ocaml install-standalone-wasm-of-ocaml: PERMS=0644
install-standalone-ocaml install-standalone-unified-ocaml install-standalone-separate-ocaml install-standalone-haskell install-standalone-unified-haskell install-standalone-separate-haskell: INSTALLDIR=$(BINDIR)
install-standalone-js-of-ocaml: INSTALLDIR=$(JSDIR)
install-standalone-wasm-of-ocaml: INSTALLDIR=$(JSDIR)
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-js-of-ocaml: FILESTOINSTALL=$(JS_OF_OCAML_FILES)
install-standalone-wasm-of-ocaml: FILESTOINSTALL=$(WASM_OF_OCAML_FILES)
install-standalone-ocaml install-standalone-unified-ocaml install-standalone-separate-ocaml install-standalone-haskell install-standalone-unified-haskell install-standalone-separate-haskell install-standalone-js-of-ocaml install-standalone-wasm-of-ocaml:
$(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 "$(INSTALLDIR)/" &&\
install -m $(PERMS) "$$f" "$(INSTALLDIR)/" &&\
echo INSTALL "$$f" "$(INSTALLDIR)/";\
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-js-of-ocaml: FILESTOINSTALL=$(WITH_BEDROCK2_JS_OF_OCAML_FILES)
install-standalone-wasm-of-ocaml: FILESTOINSTALL=$(WITH_BEDROCK2_WASM_OF_OCAML_TEXT_FILES)
install-standalone-wasm-of-ocaml: BINARYFILESTOINSTALL=$(WITH_BEDROCK2_WASM_OF_OCAML_BINARY_FILES)
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 "$(INSTALLDIR)/" &&\
install -m $(PERMS) "$$f" "$(INSTALLDIR)/$$df" &&\
echo INSTALL "$$f" "$(INSTALLDIR)/$$df";\
done
install-standalone-js-of-ocaml:
$(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 "$(INSTALLDIR)/" &&\
install -m $(PERMS) "$$f" "$(INSTALLDIR)/$$df" &&\
sed -i.bak -e 's,\(sourceMappingURL=.*\)with_bedrock2_,\1,g; s,\("file":[^"]*"[^"]*\)with_bedrock2_,\1,g' "$(INSTALLDIR)/$$df" &&\
rm -f "$(INSTALLDIR)/$$df.bak" &&\
echo 'INSTALL+SED' "$$f" "$(INSTALLDIR)/$$df";\
done
install-standalone-wasm-of-ocaml:
$(HIDE)code=0; for f in $(FILESTOINSTALL) $(BINARYFILESTOINSTALL); 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="wasm_$${fname#with_bedrock2_}" &&\
install -d "$(INSTALLDIR)/" &&\
install -m $(PERMS) "$$f" "$(INSTALLDIR)/$$df" &&\
sed -i.bak -e 's,with_bedrock2_,wasm_,g' "$(INSTALLDIR)/$$df" &&\
rm -f "$(INSTALLDIR)/$$df.bak" &&\
echo 'INSTALL+SED' "$$f" "$(INSTALLDIR)/$$df";\
done
$(HIDE)for f in $(BINARYFILESTOINSTALL); do\
fdir="$$(dirname "$$f")" &&\
fname="$$(basename "$$f")" &&\
df="wasm_$${fname#with_bedrock2_}" &&\
install -d "$(INSTALLDIR)/" &&\
install -m $(PERMS) "$$f" "$(INSTALLDIR)/$$df" &&\
echo 'INSTALL' "$$f" "$(INSTALLDIR)/$$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 uninstall-standalone-wasm-of-ocaml uninstall-standalone-js-of-ocaml:
$(HIDE)for f in $(FILESTOINSTALL); do \
instf="$(INSTALLDIR)/`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"