Debian Codegraph @

Makefile.standalone

raw
1 # IMPORTANT: This file MUST NOT introduce dependencies of the .ml/.hs
2 # files on .v files, so that we can compile them by invoking this
3 # makefile directly even when Coq is not available
4
5 .SUFFIXES:
6
7 SELF_MAKEFILE_STANDALONE := $(lastword $(MAKEFILE_LIST))
8
9 include Makefile.config
10
11 GHC?=ghc
12 GHCFLAGS?= # -XStrict
13
14 # in case we didn't include Makefile.coq
15 OCAMLFIND?=ocamlfind
16 OCAMLOPT?="$(OCAMLFIND)" ocamlopt
17 OCAMLC?="$(OCAMLFIND)" ocamlc
18 OCAMLOPTP?="$(OCAMLFIND)" ocamloptp
19 ifneq ($(WITH_PERF),1)
20 CAMLOPT_PERF ?= $(OCAMLOPT)
21 CAMLOPT_PERF_SHOW:=OCAMLOPT
22 else
23 CAMLOPT_PERF ?= $(OCAMLOPTP)
24 CAMLOPT_PERF_SHOW:=OCAMLOPTP
25 endif
26 CAMLEXTRAFLAGS ?=
27
28 JSOO_NO_INLINE?=1
29 ifneq ($(JSOO_NO_INLINE),)
30 JSOO_NO_INLINE_FLAG ?= --no-inline
31 else
32 JSOO_NO_INLINE_FLAG ?=
33 endif
34 EMIT_WAT?=1
35 ifneq ($(EMIT_WAT),)
36 EMIT_WAT_FLAG ?= --debug wat
37 else
38 EMIT_WAT_FLAG ?=
39 endif
40 JS_OF_OCAML ?= js_of_ocaml
41 WASM_OF_OCAML ?= wasm_of_ocaml
42 STANDALONE_CAMLFLAGS ?= -package unix -w -20 -g $(CAMLEXTRAFLAGS)
43 STANDALONE_JS_CAMLFLAGS ?= -package js_of_ocaml $(STANDALONE_CAMLFLAGS)
44 JS_OF_OCAML_EXTRAFLAGS ?=
45 JS_OF_OCAML_FLAGS ?= --source-map $(JSOO_NO_INLINE_FLAG) --enable=effects $(JS_OF_OCAML_EXTRAFLAGS)
46 WASM_OF_OCAML_EXTRAFLAGS ?=
47 WASM_OF_OCAML_FLAGS ?= --source-map $(JSOO_NO_INLINE_FLAG) $(EMIT_WAT_FLAG) $(WASM_OF_OCAML_EXTRAFLAGS)
48
49 PACKAGE ?= standalone.tar.gz
50 PACKAGE_CMD ?= tar -czvf
51 PACKAGE_CMD_FUNC ?= $(PACKAGE_CMD) $(1) $(2)
52 MKTEMP_D ?= etc/ci/mktemp_d.sh
53 GZIP ?= gzip
54 GZIP_KEEP_FLAGS ?= -k
55
56 ENSURE_STACK_LIMIT := . etc/ensure_stack_limit.sh || true
57
58 .PHONY: \
59 perf-standalone \
60 standalone-unified install-standalone-unified install-standalone-unified \
61 standalone-separate install-standalone-separate uninstall-standalone-separate \
62 standalone install-standalone uninstall-standalone \
63 standalone-unified-ocaml install-standalone-unified-ocaml uninstall-standalone-unified-ocaml \
64 standalone-separate-ocaml install-standalone-separate-ocaml uninstall-standalone-separate-ocaml \
65 standalone-ocaml install-standalone-ocaml uninstall-standalone-ocaml \
66 standalone-unified-haskell install-standalone-unified-haskell uninstall-standalone-unified-haskell \
67 standalone-separate-haskell install-standalone-separate-haskell uninstall-standalone-separate-haskell \
68 standalone-haskell install-standalone-haskell uninstall-standalone-haskell \
69 standalone-js-of-ocaml install-standalone-js-of-ocaml uninstall-standalone-js-of-ocaml \
70 standalone-wasm-of-ocaml install-standalone-wasm-of-ocaml uninstall-standalone-wasm-of-ocaml \
71 package-standalone package-standalone-ocaml package-standalone-haskell \
72 package-standalone-unified package-standalone-unified-ocaml package-standalone-unified-haskell \
73 package-standalone-separate package-standalone-separate-ocaml package-standalone-separate-haskell \
74 #
75
76 # pass -w -20 to disable the unused argument warning
77 # unix package needed for Unix.gettimeofday for the perf_* binaries
78 $(STANDALONE_OCAML:%=src/ExtractionOCaml/%.cmi) : %.cmi : %.ml
79 $(SHOW)'$(CAMLOPT_PERF_SHOW) $*.mli'
80 $(HIDE)$(ENSURE_STACK_LIMIT); \
81 $(TIMER) $(CAMLOPT_PERF) $(STANDALONE_CAMLFLAGS) $*.mli
82
83 $(STANDALONE_OCAML:%=src/ExtractionOCaml/%) : % : %.ml %.cmi
84 $(SHOW)'$(CAMLOPT_PERF_SHOW) $< -o $@'
85 $(HIDE)$(ENSURE_STACK_LIMIT); \
86 $(TIMER) $(CAMLOPT_PERF) $(STANDALONE_CAMLFLAGS) -linkpkg -I $(dir $@) -o $@ $<
87
88 $(STANDALONE_JS_OF_OCAML:%=src/ExtractionJsOfOCaml/%.cmi) : %.cmi : %.ml
89 $(SHOW)'OCAMLC $*.mli'
90 $(HIDE)$(ENSURE_STACK_LIMIT); \
91 $(TIMER) $(OCAMLC) $(STANDALONE_JS_CAMLFLAGS) $*.mli
92
93 $(STANDALONE_JS_OF_OCAML:%=src/ExtractionJsOfOCaml/%.byte) : %.byte : %.ml %.cmi
94 $(SHOW)'OCAMLC $< -o $@'
95 $(HIDE)$(ENSURE_STACK_LIMIT); \
96 $(TIMER) $(OCAMLC) $(STANDALONE_JS_CAMLFLAGS) -linkpkg -I $(dir $@) -o $@ $<
97
98 $(STANDALONE_JS_OF_OCAML:%=src/ExtractionJsOfOCaml/%.js) : %.js : %.byte
99 $(SHOW)'JS_OF_OCAML $<'
100 $(HIDE)$(ENSURE_STACK_LIMIT); \
101 $(TIMER) $(JS_OF_OCAML) $(JS_OF_OCAML_FLAGS) $<
102
103 $(STANDALONE_JS_OF_OCAML:%=src/ExtractionJsOfOCaml/%.wasm) : %.wasm : %.byte
104 $(SHOW)'WASM_OF_OCAML $<'
105 $(HIDE)$(ENSURE_STACK_LIMIT); \
106 $(TIMER) $(WASM_OF_OCAML) $(WASM_OF_OCAML_FLAGS) $<
107
108 $(STANDALONE_JS_OF_OCAML:%=src/ExtractionJsOfOCaml/%.wat.gz) : %.wat.gz : %.wasm
109 $(SHOW)'GZIP $*'
110 $(HIDE)$(TIMER) $(GZIP) $(GZIP_KEEP_FLAGS) $*.wat
111
112 $(STANDALONE_HASKELL:%=src/ExtractionHaskell/%) : % : %.hs
113 $(SHOW)'GHC $< -o $@'
114 $(HIDE)$(TIMER) $(GHC) $(GHCFLAGS) -o $@ $<
115
116 standalone: standalone-haskell standalone-ocaml standalone-js-of-ocaml
117 standalone-unified: standalone-unified-haskell standalone-unified-ocaml standalone-js-of-ocaml
118 standalone-separate: standalone-separate-haskell standalone-separate-ocaml
119 perf-standalone: $(PERF_STANDALONE:%=src/ExtractionOCaml/%)
120
121 standalone-ocaml: standalone-unified-ocaml standalone-separate-ocaml
122 standalone-unified-ocaml: $(UNIFIED_STANDALONE_OCAML:%=src/ExtractionOCaml/%)
123 standalone-separate-ocaml: $(SEPARATE_STANDALONE_OCAML:%=src/ExtractionOCaml/%)
124 standalone-haskell: standalone-unified-haskell standalone-separate-haskell
125 standalone-unified-haskell: $(UNIFIED_STANDALONE_HASKELL:%=src/ExtractionHaskell/%)
126 standalone-separate-haskell: $(SEPARATE_STANDALONE_HASKELL:%=src/ExtractionHaskell/%)
127 standalone-js-of-ocaml: $(STANDALONE_JS_OF_OCAML:%=src/ExtractionJsOfOCaml/%.js)
128 standalone-wasm-of-ocaml: $(STANDALONE_WASM_OF_OCAML:%=src/ExtractionJsOfOCaml/%.wasm)
129 ifneq ($(EMIT_WAT),)
130 standalone-wasm-of-ocaml: $(STANDALONE_WASM_OF_OCAML:%=src/ExtractionJsOfOCaml/%.wat.gz)
131 endif
132
133 uninstall-standalone-ocaml:: FILESTOINSTALL=$(OCAML_BINARIES)
134 uninstall-standalone-unified-ocaml:: FILESTOINSTALL=$(UNIFIED_OCAML_BINARIES)
135 uninstall-standalone-separate-ocaml:: FILESTOINSTALL=$(SEPARATE_OCAML_BINARIES)
136 uninstall-standalone-haskell:: FILESTOINSTALL=$(HASKELL_BINARIES)
137 uninstall-standalone-unified-haskell:: FILESTOINSTALL=$(UNIFIED_HASKELL_BINARIES)
138 uninstall-standalone-separate-haskell:: FILESTOINSTALL=$(SEPARATE_HASKELL_BINARIES)
139 uninstall-standalone-js-of-ocaml:: FILESTOINSTALL=$(JS_OF_OCAML_FILES)
140 uninstall-standalone-wasm-of-ocaml:: FILESTOINSTALL=$(WASM_OF_OCAML_FILES)
141 uninstall-standalone-wasm-of-ocaml: EXTRAFILESTOINSTALL=$(WASM_OF_OCAML_EXTRA_FILES)
142 uninstall-standalone-wasm-of-ocaml:: EXTRAFILESBASEDIR=$(WASM_OF_OCAML_BASEDIR)
143
144 install-standalone-ocaml install-standalone-unified-ocaml install-standalone-separate-ocaml install-standalone-haskell install-standalone-unified-haskell install-standalone-separate-haskell:: PERMS=0755
145 install-standalone-js-of-ocaml install-standalone-wasm-of-ocaml:: PERMS=0644
146 install-standalone-ocaml install-standalone-unified-ocaml install-standalone-separate-ocaml install-standalone-haskell install-standalone-unified-haskell install-standalone-separate-haskell:: INSTALLDIR=$(BINDIR)
147 install-standalone-js-of-ocaml:: INSTALLDIR=$(JSDIR)
148 install-standalone-wasm-of-ocaml:: INSTALLDIR=$(WASMDIR)
149
150
151
152 ifeq ($(SKIP_BEDROCK2),1)
153 install-standalone-ocaml:: FILESTOINSTALL=$(OCAML_BINARIES)
154 install-standalone-unified-ocaml:: FILESTOINSTALL=$(UNIFIED_OCAML_BINARIES)
155 install-standalone-separate-ocaml:: FILESTOINSTALL=$(SEPARATE_OCAML_BINARIES)
156 install-standalone-haskell:: FILESTOINSTALL=$(HASKELL_BINARIES)
157 install-standalone-unified-haskell:: FILESTOINSTALL=$(UNIFIED_HASKELL_BINARIES)
158 install-standalone-separate-haskell:: FILESTOINSTALL=$(SEPARATE_HASKELL_BINARIES)
159 install-standalone-js-of-ocaml:: FILESTOINSTALL=$(JS_OF_OCAML_FILES)
160 install-standalone-wasm-of-ocaml:: FILESTOINSTALL=$(WASM_OF_OCAML_FILES)
161 install-standalone-wasm-of-ocaml:: EXTRAFILESTOINSTALL1=$(WASM_OF_OCAML_EXTRA_FILES_WASM)
162 install-standalone-wasm-of-ocaml:: EXTRAFILESTOINSTALL2=$(WASM_OF_OCAML_EXTRA_FILES_WASM_MAP)
163 install-standalone-wasm-of-ocaml:: EXTRAFILESTOINSTALL=$(WASM_OF_OCAML_EXTRA_FILES)
164 install-standalone-wasm-of-ocaml:: EXTRAFILESBASEDIR=$(WASM_OF_OCAML_BASEDIR)
165
166 else
167 install-standalone-ocaml:: FILESTOINSTALL=$(WITH_BEDROCK2_OCAML_BINARIES)
168 install-standalone-unified-ocaml:: FILESTOINSTALL=$(WITH_BEDROCK2_UNIFIED_OCAML_BINARIES)
169 install-standalone-separate-ocaml:: FILESTOINSTALL=$(WITH_BEDROCK2_SEPARATE_OCAML_BINARIES)
170 install-standalone-haskell:: FILESTOINSTALL=$(WITH_BEDROCK2_HASKELL_BINARIES)
171 install-standalone-unified-haskell:: FILESTOINSTALL=$(WITH_BEDROCK2_UNIFIED_HASKELL_BINARIES)
172 install-standalone-separate-haskell:: FILESTOINSTALL=$(WITH_BEDROCK2_SEPARATE_HASKELL_BINARIES)
173 install-standalone-js-of-ocaml:: FILESTOINSTALL=$(WITH_BEDROCK2_JS_OF_OCAML_FILES)
174 install-standalone-wasm-of-ocaml:: FILESTOINSTALL=$(WITH_BEDROCK2_WASM_OF_OCAML_FILES)
175 install-standalone-wasm-of-ocaml:: EXTRAFILESTOINSTALL1=$(WITH_BEDROCK2_WASM_OF_OCAML_EXTRA_FILES_WASM)
176 install-standalone-wasm-of-ocaml:: EXTRAFILESTOINSTALL2=$(WITH_BEDROCK2_WASM_OF_OCAML_EXTRA_FILES_WASM_MAP)
177 install-standalone-wasm-of-ocaml:: EXTRAFILESTOINSTALL=$(WITH_BEDROCK2_WASM_OF_OCAML_EXTRA_FILES)
178 install-standalone-wasm-of-ocaml:: EXTRAFILESBASEDIR=$(WITH_BEDROCK2_WASM_OF_OCAML_BASEDIR)
179
180 endif
181
182 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::
183 $(HIDE)code=0; for f in $(FILESTOINSTALL); do\
184 if ! [ -f "$$f" ]; then >&2 echo $$f does not exist; code=1; fi \
185 done; exit $$code
186
187 install-standalone-wasm-of-ocaml::
188 $(HIDE)code=0; if [ -z "$(strip $(wildcard $(EXTRAFILESTOINSTALL1)))" ]; then \
189 >&2 echo "Missing $(EXTRAFILESTOINSTALL1)"; code=1; \
190 fi; \
191 if [ -z "$(strip $(wildcard $(EXTRAFILESTOINSTALL2)))" ]; then \
192 >&2 echo "Missing $(EXTRAFILESTOINSTALL2)"; code=1; \
193 fi; \
194 exit $$code
195
196 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::
197 $(HIDE)for f in $(FILESTOINSTALL); do\
198 install -d "$(INSTALLDIR)/" &&\
199 install -m $(PERMS) "$$f" "$(INSTALLDIR)/" &&\
200 echo INSTALL "$$f" "$(INSTALLDIR)/";\
201 done
202
203 install-standalone-wasm-of-ocaml::
204 $(HIDE)for f in $(patsubst $(EXTRAFILESBASEDIR)%,%,$(wildcard $(EXTRAFILESTOINSTALL))); do\
205 fdir="$$(dirname "$$f")" &&\
206 fname="$$(basename "$$f")" &&\
207 install -d "$(INSTALLDIR)/$$fdir" &&\
208 install -m $(PERMS) "$(EXTRAFILESBASEDIR)$$f" "$(INSTALLDIR)/$$fdir/" &&\
209 echo INSTALL "$(EXTRAFILESBASEDIR)$$f" "$(INSTALLDIR)/$$fdir/";\
210 done
211
212 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::
213 $(HIDE)for f in $(FILESTOINSTALL); do \
214 instf="$(INSTALLDIR)/`basename $$f`" &&\
215 rm -f "$$instf" &&\
216 echo RM "$$instf"; \
217 done
218
219 uninstall-standalone-wasm-of-ocaml::
220 $(HIDE)for f in $(wildcard $(patsubst $(EXTRAFILESBASEDIR)%,$(INSTALLDIR)/%,$(EXTRAFILESTOINSTALL))); do\
221 rm -f "$$f" &&\
222 echo RM "$$f"; \
223 done
224
225 install-standalone: install-standalone-ocaml # install-standalone-haskell
226 install-standalone-unified: install-standalone-unified-ocaml # install-standalone-unified-haskell
227 install-standalone-separate: install-standalone-separate-ocaml # install-standalone-separate-haskell
228 uninstall-standalone: uninstall-standalone-ocaml # uninstall-standalone-haskell
229 uninstall-standalone-unified: uninstall-standalone-unified-ocaml # uninstall-standalone-unified-haskell
230 uninstall-standalone-separate: uninstall-standalone-separate-ocaml # uninstall-standalone-separate-haskell
231
232 package-standalone: package-standalone-ocaml # package-standalone-haskell
233 package-standalone-unified: package-standalone-unified-ocaml # package-standalone-unified-haskell
234 package-standalone-separate: package-standalone-separate-ocaml # package-standalone-separate-haskell
235
236 package-standalone-ocaml package-standalone-unified-ocaml package-standalone-separate-ocaml package-standalone-haskell package-standalone-unified-haskell package-standalone-separate-haskell : package-standalone-% :
237 $(SHOW)'PACKAGE STANDALONE $*'
238 $(HIDE)rm -f "$(PACKAGE)"
239 +$(HIDE)standalonedir="$$(TMPDIR="$$(pwd)" $(MKTEMP_D))"; \
240 $(MAKE) -f $(SELF_MAKEFILE_STANDALONE) install-standalone-$* BINDIR="$$standalonedir" && \
241 cd "$$standalonedir" && \
242 $(call PACKAGE_CMD_FUNC,../$(PACKAGE),./*) && \
243 cd ../ && \
244 rm -rf "$$standalonedir"