forked from OCamlPro/alt-ergo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
353 lines (278 loc) · 9.46 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
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# ====================================
# Variable Definitions & Configuration
# ====================================
NAME=alt-ergo
SRC_DIR := src
BIN_DIR := $(SRC_DIR)/bin
LIB_DIR := $(SRC_DIR)/lib
PLUGINS_DIR := $(SRC_DIR)/plugins
PARSERS_DIR := $(SRC_DIR)/parsers
COMMON_DIR := $(BIN_DIR)/common
BTEXT_DIR := $(BIN_DIR)/text
BJS_DIR := $(BIN_DIR)/js
UTIL_DIR := $(LIB_DIR)/util
FTND_DIR := $(LIB_DIR)/frontend
RSNRS_DIR := $(LIB_DIR)/reasoners
STRCT_DIR := $(LIB_DIR)/structures
RSC_DIR := rsc
EXTRA_DIR := $(RSC_DIR)/extra
SPHINX_DOC_DIR := docs/sphinx_docs
BUILD_DIR := _build
INSTALL_DIR := $(BUILD_DIR)/install
DEFAULT_DIR := $(BUILD_DIR)/default
SPHINX_BUILD_DIR := $(BUILD_DIR)/sphinx_docs
# Some variables to help with adding
# flags and/or renaming the dune binary
DUNE=dune
DUNE_FLAGS?=
# Definining the sphinx build command
SPHINXBUILD = sphinx-build
# List the files:
# - generated by rules in this makefile,
# - used by the build process
#
# This excludes:
# - .ml files generated by menhir or ocamllex
# (since they reside in dune specific directory)
GENERATED_LINKS=alt-ergo alt-ergo.js alt-ergo-worker.js AB-Why3-plugin.cma AB-Why3-plugin.cmxs fm-simplex-plugin.cma fm-simplex-plugin.cmxs
GENERATED=$(GENERATED_LINKS)
# =======
# Aliases
# =======
# IMPORTANT: this is the first rules, and as such the default
# run when "make" is called, keep it as the first rule
world: all
# Alias for generated artifacts
clean: generated-clean dune-clean ocamldot-clean
# Alias to remove all generated files
distclean: makefile-distclean release-distclean
# declare these aliases as phony
.PHONY: world conf clean distclean alt-ergo-lib \
alt-ergo-parsers alt-ergo
# =================
# Build rules (dev)
# =================
lib:
$(DUNE) build $(DUNE_FLAGS) @$(LIB_DIR)/all
bin:
$(DUNE) build $(DUNE_FLAGS) @$(BTEXT_DIR)/all
ln -sf src/bin/text/Main_text.exe alt-ergo
parsers:
$(DUNE) build $(DUNE_FLAGS) @$(PARSERS_DIR)/all
fm-simplex:
$(DUNE) build $(DUNE_FLAGS) @$(PLUGINS_DIR)/fm-simplex/all
$(DUNE) build $(DUNE_FLAGS) @install
AB-Why3:
$(DUNE) build $(DUNE_FLAGS) @$(PLUGINS_DIR)/AB-Why3/all
$(DUNE) build $(DUNE_FLAGS) alt-ergo-plugin-ab-why3.install
plugins:
$(DUNE) build $(DUNE_FLAGS) @$(PLUGINS_DIR)/all
# Alias to build all the bytecode artefacts using dune
# Hopefully more efficient than making "all" depend
# on "lib" and "bin", since dune can parralelize more
all:
$(DUNE) build $(DUNE_FLAGS) @$(SRC_DIR)/all @examples/all
ln -sf src/bin/text/Main_text.exe alt-ergo
# declare these targets as phony to avoid name clashes with existing directories,
# particularly the "plugins" target
.PHONY: lib bin fm-simplex AB-Why3 plugins all
# =====================
# Build rules (release)
# =====================
packages:
$(DUNE) build $(DUNE_FLAGS) --release
.PHONY: packages
# ==============
# Generate tests
# ==============
# Generate dummy expected file for new tests.
genexpected:
dune exec -- tools/gentest.exe --kind expected tests >/dev/null
# Run non-regression tests.
runtest: genexpected bin
dune build @runtest @runtest-quick
# Run non-regression tests for the CI.
runtest-ci: genexpected bin
dune build @runtest @runtest-quick @runtest-ci
# Promote new outputs of the tests.
promote:
dune promote
.PHONY: runtest runtest-ci promote
# ============
# Installation
# ============
# Installation using dune is *NOT* recommended
# The good way to install alt-ergo is to use the alt-ergo.install
# file generated by dune, which specifies all files that need to
# be copied, and where they should be copied
install: packages
$(DUNE) install --release
uninstall: packages
$(DUNE) uninstall
.PHONY: install uninstall
# ========================
# Documentation generation
# ========================
# Build the documentations
doc: odoc sphinx-doc
# Build the sphinx documentation
sphinx-doc:
# cp LICENSE.md $(SPHINX_DOC_DIR)/About/license.md
# cp -r licenses $(SPHINX_DOC_DIR)/About
$(SPHINXBUILD) "$(SPHINX_DOC_DIR)" "$(SPHINX_BUILD_DIR)"
# Build the odoc
odoc:
$(DUNE) build $(DUNE_FLAGS) @doc
# Open the html doc generated by sphinx and odoc in browser
html: doc
mkdir -p $(SPHINX_BUILD_DIR)/odoc/dev
cp -r $(DEFAULT_DIR)/_doc/_html/* $(SPHINX_BUILD_DIR)/odoc/dev
xdg-open $(SPHINX_BUILD_DIR)/index.html
.PHONY: doc sphinx-doc odoc html
# ======================
# Javascript generation
# ======================
# Build the text alt-ergo bin in Js with js_of_ocaml-compiler
# zarith_stubs_js package is needed for this rule
# note that --timeout option is ignored due to the lack of js primitives
# and the use of input zip file is also unavailable
js-node:
$(DUNE) build $(DUNE_FLAGS) --profile=release $(BJS_DIR)/main_text_js.bc.js
ln -sf $(DEFAULT_DIR)/$(BJS_DIR)/main_text_js.bc.js alt-ergo.js
# Build a web worker for alt-ergo
# zarith_stubs_js, data-encoding, js_of_ocaml and js_of_ocaml-lwt packages are needed for this rule
js-worker:
$(DUNE) build $(DUNE_FLAGS) --profile=release $(BJS_DIR)/worker_js.bc.js
ln -sf $(DEFAULT_DIR)/$(BJS_DIR)/worker_js.bc.js alt-ergo-worker.js \
# Build a small web example using the alt-ergo web worker
# This example is available in the www/ directory
# zarith_stubs_js, data-encoding, js_of_ocaml and js_of_ocaml-lwt js_of_ocaml-ppx lwt_ppx packages are needed for this rule
js-example: js-worker
$(DUNE) build $(DUNE_FLAGS) --profile=release $(BJS_DIR)/worker_example.bc.js
mkdir -p www
cp $(EXTRA_DIR)/worker_example.html www/index.html
cd www \
&& ln -sf ../$(DEFAULT_DIR)/$(BJS_DIR)/worker_js.bc.js alt-ergo-worker.js \
&& ln -sf ../$(DEFAULT_DIR)/$(BJS_DIR)/worker_example.bc.js alt-ergo-main.js
.PHONY: js-node js-worker js-example
# ================
# Dependency graph
# ================
$(EXTRA_DIR)/ocamldot/ocamldot:
cd $(EXTRA_DIR)/ocamldot/ && $(MAKE) bin
# plot the dependency graph
# specifying all dependencies is really, really bothersome,
# so we just put the ocamldot executable as dep
archi: $(EXTRA_DIR)/ocamldot/ocamldot
ocamldep \
-I $(BIN_DIR)/ -I $(LIB_DIR)/ -I $(COMMON_DIR)/ -I $(PARSERS_DIR)/ \
-I $(PLUGINS_DIR)/ -I $(BTEXT_DIR)/ \
-I $(FTND_DIR)/ -I $(RSNRS_DIR)/ -I $(STRCT_DIR)/ -I $(UTIL_DIR)/ \
-I $(DEFAULT_DIR)/$(COMMON_DIR)/ \
-I $(DEFAULT_DIR)/$(PARSERS_DIR)/ -I $(DEFAULT_DIR)/$(PLUGINS_DIR)/ \
$(FTND_DIR)/*.ml $(RSNRS_DIR)/*.ml $(STRCT_DIR)/*.ml $(UTIL_DIR)/*.ml \
$(COMMON_DIR)/*.ml $(DEFAULT_DIR)/$(COMMON_DIR)/*.ml \
$(PARSERS_DIR)/*.ml $(DEFAULT_DIR)/$(PARSERS_DIR)/*.ml \
$(PLUGINS_DIR)/*/*.ml $(DEFAULT_DIR)/$(PLUGINS_DIR)/*/*.ml \
$(BTEXT_DIR)/*.ml | \
$(EXTRA_DIR)/ocamldot/ocamldot | grep -v "}" > archi.dot
cat $(EXTRA_DIR)/subgraphs.dot >> archi.dot
echo "}" >> archi.dot
dot -Tpdf archi.dot > archi.pdf
lock:
dune build ./alt-ergo-lib.opam
opam lock ./alt-ergo-lib.opam -w
# Remove OCaml compiler constraints
sed -i \
'/"ocaml"\|"ocaml-base-compiler"\|"ocaml-system"\|"ocaml-config"\|"base-domains"\|"base-nnp"/d' \
./alt-ergo-lib.opam.locked
dev-switch:
opam switch create . --deps-only --ignore-constraints-on alt-ergo-lib,alt-ergo-parsers
js-deps:
opam install \
'js_of_ocaml>=5.4.0' \
js_of_ocaml-lwt \
js_of_ocaml-ppx \
data-encoding \
'zarith_stubs_js>=v0.16.1' \
lwt_ppx -y
deps:
opam install . --deps-only
test-deps:
opam install . --deps-only --with-test
dune-deps:
dune-deps . | dot -Tpng -o docs/deps.png
.PHONY: archi deps test-deps dune-deps dev-switch lock
# ===============
# PUBLIC RELEASES
# ===============
# Get the current commit hash and version number
VCS_COMMIT_ID = $(shell git rev-parse HEAD)
# Use the same command as dune subst
VERSION=$(shell git describe --always --dirty --abbrev=7)
# vX.Y.Z -> X.Y.Z
VERSION_NUM=$(VERSION:v%=%)
# Some convenient variables
PUBLIC_RELEASE=alt-ergo-$(VERSION_NUM)
PUBLIC_TARGZ=$(PUBLIC_RELEASE).tar.gz
FILES_DEST=public-release/$(PUBLIC_RELEASE)
--prepare-release:
git clean -dfxi
mkdir -p $(FILES_DEST)
cp --parents -r \
docs \
examples \
licenses/Apache-License-2.0.txt \
licenses/OCamlPro-Non-Commercial-License.pdf \
licenses/OCamlPro-Non-Commercial-License.txt \
licenses/LGPL-License.txt \
non-regression \
rsc \
src \
tests \
alt-ergo.opam \
alt-ergo-lib.opam \
alt-ergo-parsers.opam \
dune-project \
Makefile \
README.md \
LICENSE.md \
CHANGES.md \
$(FILES_DEST)
sed -i "s/%%VERSION_NUM%%/$(VERSION_NUM)/" $(FILES_DEST)/$(UTIL_DIR)/version.ml
sed -i "s/%%VCS_COMMIT_ID%%/$(VCS_COMMIT_ID)/" $(FILES_DEST)/$(UTIL_DIR)/version.ml
sed -i "s/%%BUILD_DATE%%/`LANG=en_US; date`/" $(FILES_DEST)/$(UTIL_DIR)/version.ml
public-release: --prepare-release
cd public-release && tar cfz $(PUBLIC_TARGZ) $(PUBLIC_RELEASE)
rm -rf $(FILES_DEST)
free-public-release: --prepare-release
cp licenses/CeCILL-C-License-v1.txt $(FILES_DEST)
find src/lib src/bin src/parsers -iname "*.ml*" -exec headache -h licenses/free-header.txt {} \;
cd public-release && tar cfz $(PUBLIC_TARGZ) $(PUBLIC_RELEASE)
git restore $(SRC_DIR)
rm -rf $(FILES_DEST)
# ==============
# Cleaning rules
# ==============
# Cleanup generated files
generated-clean:
rm -rf $(GENERATED)
# Clean build artifacts
dune-clean:
$(DUNE) clean
# Clean js example files
js-clean:
rm -rf www
# Clean ocamldot's build artifacts
ocamldot-clean:
cd $(EXTRA_DIR)/ocamldot && $(MAKE) clean
# Cleanup all makefile-related files
makefile-distclean: generated-clean
# Clenaup release generated files and dirs
release-distclean:
rm -rf public-release
.PHONY: generated-clean dune-clean js-clean makefile-distclean release-distclean
emacs-edit:
emacs `find . -name '*'.ml* | grep -v _build | grep -v _opam` &
modules-dep-graph dep-graph:
rsc/extra/gen-modules-dep-graph.sh