Makefile.in 76.2 KB
Newer Older
1 2 3
####################################################################
#                                                                  #
#  The Why3 Verification Platform   /   The Why3 Development Team  #
Guillaume Melquiond's avatar
Guillaume Melquiond committed
4
#  Copyright 2010-2019   --   Inria - CNRS - Paris-Sud University  #
5 6 7 8 9 10
#                                                                  #
#  This software is distributed under the terms of the GNU Lesser  #
#  General Public License version 2.1, with the special exception  #
#  on linking described in file LICENSE.                           #
#                                                                  #
####################################################################
11

12 13 14
VERBOSEMAKE ?= @enable_verbose_make@

ifeq ($(VERBOSEMAKE),yes)
15 16
  SHOW = @true
  HIDE =
17
else
18 19
  SHOW = @echo
  HIDE = @
20 21
endif

22
# install the binaries
23
DESTDIR =
24

25
prefix	    = @prefix@
26 27 28 29 30
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@

BINDIR  = $(DESTDIR)@bindir@
LIBDIR  = $(DESTDIR)@libdir@
31
DATADIR = $(DESTDIR)@datarootdir@
32
MANDIR  = $(DESTDIR)@mandir@
33
TOOLDIR = $(LIBDIR)/why3/commands
34

Andrei Paskevich's avatar
Andrei Paskevich committed
35
# OS specific stuff
36
EXE   = @EXE@
37 38

# other variables
39
CC        = @CC@
40 41 42
MKDIR_P   = @MKDIR_P@
INSTALL   = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
43 44 45 46 47 48 49
OCAMLC    = @OCAMLC@
OCAMLOPT  = @OCAMLOPT@
OCAMLDEP  = @OCAMLDEP@
OCAMLLEX  = @OCAMLLEX@
OCAMLYACC = @OCAMLYACC@
OCAMLDOC  = @OCAMLDOC@
OCAMLLIB  = @OCAMLLIB@
50
OCAMLINSTALLLIB  = $(DESTDIR)@OCAMLINSTALLLIB@
51 52
OCAMLBEST = @OCAMLBEST@
OCAMLVERSION = @OCAMLVERSION@
53 54
COQC      = @COQC@
COQDEP    = @COQDEP@
MARCHE Claude's avatar
MARCHE Claude committed
55
FRAMAC_LIBDIR = $(DESTDIR)@FRAMAC_LIBDIR@
56 57
MENHIR	  = @MENHIR@

58 59 60 61 62
DEPFLAGS = -slash

ifeq (@enable_why3_lib@,yes)
DEPFLAGS += -I lib/why3
endif
63
ifeq (@OCAMLBEST@,opt)
64 65
# the semantics of the -native flag changed in ocaml 4.03.0
#DEPFLAGS += -native
66 67
endif

68
RUBBER = @RUBBER@
69
HEVEA = @HEVEA@
70
HACHA = @HACHA@
71
EMACS = @EMACS@
72

73
#PSVIEWER  = @PSVIEWER@
Andrei Paskevich's avatar
Andrei Paskevich committed
74
#PDFVIEWER = @PDFVIEWER@
75

76
INCLUDES = @WHY3INCLUDE@ @ZIPINCLUDE@ @MENHIRINCLUDE@ @NUMINCLUDE@
77 78 79 80 81 82 83 84 85 86

# warnings are enabled and non fatal by default, except:
# - disabled:
#   4    Fragile pattern matching: matching that will remain complete even
#        if additional constructors are added to one of the variant types
#        matched.
#   9    Missing fields in a record pattern.
#   41   Ambiguous constructor or label name.
#   44   Open statement shadows an already defined identifier.
#   45   Open statement shadows an already defined label or constructor.
87
#   50   Unexpected documentation comment.
88 89 90
#   52   The argument of this constructor should not be matched against a
#        constant pattern; the actual value of the argument could change
#        in the future.
91 92 93
# - fatal:
#   5    Partially applied function: expression whose result has function
#        type and is ignored.
94
#   8    Partial match: missing cases in pattern-matching.
Andrei Paskevich's avatar
Andrei Paskevich committed
95
#   48   Implicit elimination of optional arguments.
96

François Bobot's avatar
François Bobot committed
97
WARNINGS = A-4-9-41-44-45-50-52@5@8@48
98

99 100
OFLAGS = -w $(WARNINGS) -safe-string -keep-locs -bin-annot -dtypes -g $(INCLUDES)
BFLAGS = -w $(WARNINGS) -safe-string -keep-locs -bin-annot -dtypes -g $(INCLUDES)
101 102 103

OLINKFLAGS = -linkall $(EXTCMXA)
BLINKFLAGS = -linkall $(EXTCMA)
104

105
ifeq (@enable_profiling@,yes)
106 107 108
OFLAGS += -g -p
endif

109 110 111
# see http://caml.inria.fr/mantis/view.php?id=4991
CMIHACK = -intf-suffix .cmi

112 113
# external libraries common to all binaries

114
EXTOBJS = menhirLib
115
EXTLIBS = str unix nums dynlink @ZIPLIB@ @WHY3LIB@
116

117 118
EXTCMA	= $(addsuffix .cmo,$(EXTOBJS)) $(addsuffix .cma,$(EXTLIBS))
EXTCMXA = $(addsuffix .cmx,$(EXTOBJS)) $(addsuffix .cmxa,$(EXTLIBS))
119

120 121
INSTALLED_LIB_EXTS = a cma cmx cmi cmxa cmxs
COMPILED_LIB_EXTS = $(INSTALLED_LIB_EXTS) o cmo cmt cmti annot dep conflicts
122

123 124
TOTARGET = > "$@" || (RV=$$?; rm -f "$@"; exit $${RV})

125 126
# Variables added for checking realizations
GENERATED_PREFIX_COQ="lib/coq"
127
GENERATED_PREFIX_ISABELLE=lib/isabelle
128

129 130 131 132 133 134 135
ifeq (@enable_why3_lib@,yes)
WHY3CMA  = lib/why3/why3.cma
WHY3CMXA = lib/why3/why3.cmxa
else
WHY3CMA  =
WHY3CMXA =
endif
136

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
137 138 139
###############
# main target
###############
140

141
ifeq (@enable_why3_lib@,yes)
142
all: @OCAMLBEST@
143 144 145 146
else
all:
endif

147 148 149
plugins: plugins.@OCAMLBEST@
opt: plugins.opt
byte: plugins.byte
Francois Bobot's avatar
Francois Bobot committed
150

151 152 153 154
ifeq (@enable_local@,yes)
all: install_local
endif

155 156 157 158
.PHONY: byte opt clean depend all install install-lib uninstall
.PHONY: install-bin install-data uninstall-bin uninstall-data
.PHONY: install-bash install-emacs install-framac
.PHONY: uninstall-bash uninstall-emacs uninstall-framac
159
.PHONY: ide install-ide uninstall-ide
160 161
.PHONY: coq install-coq uninstall-coq clean-coq
.PHONY: pvs install-pvs uninstall-pvs clean-pvs
162
.PHONY: install-isabelle
163
.PHONY: plugins plugins.byte plugins.opt
164

165 166 167 168
CLEANDIRS =
CLEANLIBS =
GENERATED =

169 170 171
##############
# Why3 library
##############
172

173
LIBGENERATED = src/util/config.ml \
174 175 176 177
	       src/util/rc.ml src/util/lexlib.ml \
	       src/util/json_parser.mli src/util/json_parser.ml \
	       src/util/json_lexer.ml \
	       src/parser/lexer.ml \
178 179
	       src/parser/parser.mli src/parser/parser.ml \
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
180
	       src/driver/driver_lexer.ml \
181 182
	       src/driver/parse_smtv2_model_parser.mli src/driver/parse_smtv2_model_parser.ml \
	       src/driver/parse_smtv2_model_lexer.ml \
183
	       src/session/compress.ml src/session/xml.ml \
184
	       src/session/strategy_parser.ml \
185
	       lib/ocaml/why3__BigInt_compat.ml
186

187
LIB_UTIL = config bigInt util opt lists strings \
188
	   pp extmap extset exthtbl weakhtbl \
189
	   hashcons wstdlib exn_printer \
190
	   json_base json_parser json_lexer \
191
	   debug loc lexlib print_tree \
Mário Pereira's avatar
Mário Pereira committed
192
	   cmdline warning sysutil rc plugin bigInt number vector pqueue
193

194
LIB_CORE = ident ty term pattern decl coercion theory \
195
	   task pretty dterm env trans printer model_parser
196

197
LIB_DRIVER = prove_client call_provers driver_ast driver_parser driver_lexer driver \
198 199 200 201
		whyconf autodetection \
		smt2_model_defs parse_smtv2_model_parser \
		collect_data_model parse_smtv2_model_lexer parse_smtv2_model \
		parse_smtv2_model
202

203
LIB_MLW = ity expr pdecl eval_match typeinv vc pmodule dexpr \
204 205
          pinterp mltree compile mlinterp pdriver cprinter ml_printer \
	  ocaml_printer cakeml_printer
206

207
LIB_PARSER = ptree glob typing parser typing lexer
208

209
LIB_TRANSFORM = simplify_formula inlining split_goal \
210
		args_wrapper detect_polymorphism reduction_engine compute \
211
		eliminate_definition eliminate_algebraic \
212
		abstract_quantifiers eliminate_unknown_types \
213
		eliminate_unknown_lsymbols eliminate_symbol \
214
		eliminate_inductive eliminate_let eliminate_if \
215 216 217 218
		libencoding discriminate encoding encoding_select \
		encoding_guards_full encoding_tags_full \
		encoding_guards encoding_tags encoding_twin \
		encoding_sort simplify_array filter_trigger \
219
		abstraction close_epsilon lift_epsilon \
220
		eliminate_epsilon intro_projections_counterexmp \
Andrei Paskevich's avatar
Andrei Paskevich committed
221
		instantiate_predicate smoke_detector \
222
		prop_curry eliminate_literal \
223
		generic_arg_trans_utils case apply subst \
224
		introduction ind_itp destruct cut congruence \
225
		intro_vc_vars_counterexmp prepare_for_counterexmp \
226
		induction induction_pr matching reflection
227

Sylvain Dailler's avatar
Sylvain Dailler committed
228
LIB_PRINTER = cntexmp_printer alt_ergo why3printer smtv1 smtv2 coq\
229
	      pvs isabelle \
230
	      simplify gappa cvc3 yices mathematica
231

232 233 234
LIB_SESSION = compress xml termcode session_itp \
              strategy strategy_parser controller_itp \
	      server_utils itp_communication \
235
	      itp_server json_util
236

237
LIBMODULES =  $(addprefix src/util/, $(LIB_UTIL)) \
238 239
	      $(addprefix src/core/, $(LIB_CORE)) \
	      $(addprefix src/driver/, $(LIB_DRIVER)) \
240
	      $(addprefix src/mlw/, $(LIB_MLW)) \
241
	      $(addprefix src/parser/, $(LIB_PARSER)) \
242
	      $(addprefix src/transform/, $(LIB_TRANSFORM)) \
François Bobot's avatar
François Bobot committed
243
	      $(addprefix src/printer/, $(LIB_PRINTER)) \
244
	      $(addprefix src/session/, $(LIB_SESSION))
245

246
LIBDIRS = util core driver mlw parser transform printer session
247
LIBINCLUDES = $(addprefix -I src/, $(LIBDIRS))
MARCHE Claude's avatar
MARCHE Claude committed
248

249
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
250 251
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
252

253
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
254
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
255
$(LIBCMX): OFLAGS += -for-pack Why3
256

257 258
$(LIBDEP): $(LIBGENERATED)

259 260 261
# Zarith

ifeq (@enable_zarith@,yes)
262
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_zarith.ml
263
	cp lib/ocaml/why3__BigInt_zarith.ml $@
264
else
265
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_num.ml
266
	cp lib/ocaml/why3__BigInt_num.ml $@
267 268
endif

269 270 271 272 273 274 275 276 277 278
# Ocamlzip

ifeq (@enable_zip@,yes)
src/session/compress.ml: config.status src/session/compress_z.ml
	cp src/session/compress_z.ml $@
else
src/session/compress.ml: config.status src/session/compress_none.ml
	cp src/session/compress_none.ml $@
endif

279 280
# hide deprecated warnings for strings

281 282
src/util/strings.cmo: WARNINGS:=$(WARNINGS)-3
src/util/strings.cmx: WARNINGS:=$(WARNINGS)-3
283

284 285 286
# compiler plugins

ifeq (@enable_compiler_plugins@,yes)
287
src/util/debug_optim.cmxs: src/util/debug_optim.ml
288
	$(SHOW) 'Linking $@'
289
	$(HIDE)$(OCAMLOPT) -I @COMPILERLIBS@ -shared src/util/debug_optim.ml -o $@
290 291 292 293
src/transform/reflection.cmx: src/util/debug_optim.cmxs
src/transform/reflection.cmx: OFLAGS += -plugin debug_optim.cmxs
src/mlw/mlinterp.cmx: src/util/debug_optim.cmxs
src/mlw/mlinterp.cmx: OFLAGS += -plugin debug_optim.cmxs
294 295
endif

296
# build targets
297

298
byte: lib/why3/why3.cma
299
opt:  lib/why3/why3.cmxa lib/why3/why3.cmxs
300

301 302
lib/why3/why3.cma: lib/why3/why3.cmo
lib/why3/why3.cmxa: lib/why3/why3.cmx
303
lib/why3/why3.cmxs: lib/why3/why3.cmx
304

305
lib/why3/why3.cmo: $(LIBCMO)
306 307
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $^
308

309
lib/why3/why3.cmx: $(LIBCMX) lib/why3/why3.cmo
310
	$(SHOW) 'Linking  $@'
311
	$(HIDE)$(OCAMLOPT) $(OFLAGS) $(CMIHACK) -pack -o $@ $(filter %.cmx, $^)
312

313
# clean and depend
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
314

315
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
316
-include $(LIBDEP)
317
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
318

319
depend: $(LIBDEP)
320

321
CLEANDIRS += src $(addprefix src/, $(LIBDIRS))
322
CLEANLIBS += lib/why3/why3
323
GENERATED += $(LIBGENERATED)
324

325 326 327
###############
# installation
###############
328

329
uninstall-data::
MARCHE Claude's avatar
MARCHE Claude committed
330 331
	rm -rf $(DATADIR)/why3

332
install-data::
333 334
	$(MKDIR_P) $(DATADIR)/why3
	$(MKDIR_P) $(DATADIR)/why3/vim
335 336
	$(MKDIR_P) $(DATADIR)/why3/vim/ftdetect
	$(MKDIR_P) $(DATADIR)/why3/vim/syntax
337
	$(MKDIR_P) $(DATADIR)/why3/lang
338 339
	$(MKDIR_P) $(DATADIR)/why3/stdlib
	$(MKDIR_P) $(DATADIR)/why3/stdlib/mach
340
	$(MKDIR_P) $(DATADIR)/why3/drivers
341
	$(INSTALL_DATA) stdlib/*.mlw $(DATADIR)/why3/stdlib
342
	$(INSTALL_DATA) stdlib/mach/*.mlw $(DATADIR)/why3/stdlib/mach
343 344 345 346 347
	$(INSTALL_DATA) drivers/*.drv drivers/*.gen $(DATADIR)/why3/drivers
	$(INSTALL_DATA) LICENSE $(DATADIR)/why3/
	$(INSTALL_DATA) share/provers-detection-data.conf $(DATADIR)/why3/
	$(INSTALL_DATA) share/why3session.dtd $(DATADIR)/why3
	$(INSTALL_DATA) share/Makefile.config $(DATADIR)/why3
348 349
	$(INSTALL_DATA) share/vim/ftdetect/why3.vim $(DATADIR)/why3/vim/ftdetect/why3.vim
	$(INSTALL_DATA) share/vim/syntax/why3.vim $(DATADIR)/why3/vim/syntax/why3.vim
350
	$(INSTALL_DATA) share/lang/why3.lang $(DATADIR)/why3/lang/why3.lang
351

352 353
ifeq (@enable_local@,yes)
else
354 355 356 357
install:: install-bin install-data

uninstall:: uninstall-bin uninstall-data
	rm -rf $(LIBDIR)/why3
358 359
endif

360 361 362 363
uninstall-lib:
	if test -d $(OCAMLINSTALLLIB) -a -w $(OCAMLINSTALLLIB); then \
	  rm -rf $(OCAMLINSTALLLIB)/why3; \
	fi
MARCHE Claude's avatar
MARCHE Claude committed
364

365
uninstall:: uninstall-lib
Kate's avatar
Kate committed
366

367 368 369 370
install-lib::
	$(MKDIR_P) $(OCAMLINSTALLLIB)/why3
	$(INSTALL_DATA) $(wildcard $(addprefix lib/why3/why3., $(INSTALLED_LIB_EXTS))) \
		lib/why3/META $(OCAMLINSTALLLIB)/why3
Kate's avatar
Kate committed
371

372 373 374 375 376 377 378
##################
# Why3 emacs mode
##################

%.elc: %.el
	$(EMACS) --batch --no-init-file -f batch-byte-compile $<

379
uninstall-emacs:
Kate's avatar
Kate committed
380 381 382
	rm -f $(DATADIR)/emacs/site-lisp/why3.el
	rm -f $(DATADIR)/emacs/site-lisp/why3.elc

383 384 385
uninstall:: uninstall-emacs

install-emacs:
386
	$(MKDIR_P) $(DATADIR)/emacs/site-lisp/
387
	$(INSTALL_DATA) share/emacs/why3.el $(DATADIR)/emacs/site-lisp/why3.el
388
ifeq (@enable_emacs_compilation@,yes)
389
	$(INSTALL_DATA) share/emacs/why3.elc $(DATADIR)/emacs/site-lisp/why3.elc
Kate's avatar
Kate committed
390 391
endif

392 393
install:: install-emacs

394
ifeq (@enable_emacs_compilation@,yes)
395
all: share/emacs/why3.elc
396 397
endif

Kate's avatar
Kate committed
398

399
##################
400
# Why3 plugins
401 402
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
403
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
404
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
405 406
		plugins/python/py_lexer.ml \
		plugins/python/py_parser.ml plugins/python/py_parser.mli \
407
		plugins/parser/dimacs.ml \
408

409
PLUG_PARSER = genequlin dimacs
410
PLUG_PRINTER =
411
PLUG_TRANSFORM =
412
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
413
PLUG_PYTHON = py_ast py_parser py_lexer py_main
414

415
PLUGINS = genequlin dimacs tptp python
416

417
TPTPMODULES = $(addprefix plugins/tptp/, $(PLUG_TPTP))
418
PYTHONMODULES = $(addprefix plugins/python/, $(PLUG_PYTHON))
Andrei Paskevich's avatar
Andrei Paskevich committed
419

420 421
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
422

423 424 425
PYTHONCMO = $(addsuffix .cmo, $(PYTHONMODULES))
PYTHONCMX = $(addsuffix .cmx, $(PYTHONMODULES))

426 427 428 429 430 431 432 433 434 435
ifeq (@enable_hypothesis_selection@,yes)
PLUG_TRANSFORM += hypothesis_selection
PLUGINS += hypothesis_selection

lib/plugins/hypothesis_selection.cmxs: INCLUDES += -I @OCAMLGRAPHLIB@
lib/plugins/hypothesis_selection.cmo:  INCLUDES += -I @OCAMLGRAPHLIB@
lib/plugins/hypothesis_selection.cmxs: OFLAGS += graph.cmxa
lib/plugins/hypothesis_selection.cmo:  BFLAGS += graph.cmo
endif

436 437
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
438
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
439
	      $(TPTPMODULES) $(PYTHONMODULES)
440

441
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
442 443 444
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

445
PLUGDIRS = parser printer transform tptp python
446 447
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

448
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
449 450
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

451 452
$(PLUGDEP): $(PLUGGENERATED)

453 454
LIBPLUGCMO =  $(PLUGINS:%=lib/plugins/%.cmo)
LIBPLUGCMXS = $(PLUGINS:%=lib/plugins/%.cmxs)
455 456 457

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
458

459 460
lib/plugins:
	mkdir lib/plugins
461

462
lib/plugins/%.cmxs: | lib/plugins
463
	$(SHOW) 'Linking  $@'
464
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -shared -o $@ $^
465

466
lib/plugins/%.cmo: | lib/plugins
467
	$(SHOW) 'Linking  $@'
468
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $^
469

470 471
lib/plugins/%.cmxs: plugins/parser/%.cmx
lib/plugins/%.cmo: plugins/parser/%.cmo
472 473 474 475
lib/plugins/%.cmxs: plugins/printer/%.cmx
lib/plugins/%.cmo: plugins/printer/%.cmo
lib/plugins/%.cmxs: plugins/transform/%.cmx
lib/plugins/%.cmo: plugins/transform/%.cmo
476 477
lib/plugins/tptp.cmxs: $(TPTPCMX)
lib/plugins/tptp.cmo: $(TPTPCMO)
478 479
lib/plugins/python.cmxs: $(PYTHONCMX)
lib/plugins/python.cmo: $(PYTHONCMO)
480

481 482
# depend and clean targets

483
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
484
-include $(PLUGDEP)
485 486
endif

487
depend: $(PLUGDEP)
488

489 490
CLEANDIRS += plugins $(addprefix plugins/, $(PLUGDIRS)) lib/plugins
GENERATED += $(PLUGGENERATED)
491

492 493 494 495 496
uninstall-bin::
	rm -f $(PLUGINS:%=$(LIBDIR)/why3/plugins/%.cmo)
	rm -f $(PLUGINS:%=$(LIBDIR)/why3/plugins/%.cmxs)

install-bin::
497 498
	$(MKDIR_P) $(LIBDIR)/why3/plugins
	$(INSTALL_DATA) $(wildcard $(LIBPLUGCMO) $(LIBPLUGCMXS)) $(LIBDIR)/why3/plugins
499

500 501 502 503
###############
# Why3 commands
###############

504 505 506 507 508
TOOLSGENERATED = src/tools/why3wc.ml

TOOLS_BIN = why3config why3execute why3extract why3prove \
	    why3realize why3replay why3wc

509
TOOLS_FILES = main $(TOOLS_BIN)
510 511 512 513 514 515 516 517 518 519

TOOLSMODULES = $(addprefix src/tools/, $(TOOLS_FILES))

TOOLSDEP = $(addsuffix .dep, $(TOOLSMODULES))
TOOLSCMO = $(addsuffix .cmo, $(TOOLSMODULES))
TOOLSCMX = $(addsuffix .cmx, $(TOOLSMODULES))

$(TOOLSDEP): DEPFLAGS += -I src/tools
$(TOOLSCMO) $(TOOLSCMX): INCLUDES += -I src/tools

520 521
$(TOOLSDEP): $(TOOLSGENERATED)

522 523 524
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

525 526 527
bin:
	mkdir bin

528 529 530 531 532 533 534 535 536 537 538 539 540 541
bin/why3.opt: $(WHY3CMXA) src/tools/main.cmx
bin/why3.byte: $(WHY3CMA) src/tools/main.cmo
bin/why3config.opt: $(WHY3CMXA) src/tools/why3config.cmx
bin/why3config.byte: $(WHY3CMA) src/tools/why3config.cmo
bin/why3execute.opt: $(WHY3CMXA) src/tools/why3execute.cmx
bin/why3execute.byte: $(WHY3CMA) src/tools/why3execute.cmo
bin/why3extract.opt: $(WHY3CMXA) src/tools/why3extract.cmx
bin/why3extract.byte: $(WHY3CMA) src/tools/why3extract.cmo
bin/why3prove.opt: $(WHY3CMXA) src/tools/why3prove.cmx
bin/why3prove.byte: $(WHY3CMA) src/tools/why3prove.cmo
bin/why3realize.opt: $(WHY3CMXA) src/tools/why3realize.cmx
bin/why3realize.byte: $(WHY3CMA) src/tools/why3realize.cmo
bin/why3replay.opt: $(WHY3CMXA) src/tools/unix_scheduler.cmx src/tools/why3replay.cmx
bin/why3replay.byte: $(WHY3CMA) src/tools/unix_scheduler.cmo src/tools/why3replay.cmo
542 543 544
bin/why3wc.opt: src/tools/why3wc.cmx
bin/why3wc.byte: src/tools/why3wc.cmo

545 546 547
uninstall-bin::
	rm -f $(BINDIR)/why3$(EXE)
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE))
Kate's avatar
Kate committed
548

549 550
install-bin::
	$(MKDIR_P) $(BINDIR)
551
	$(INSTALL) bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
552
	$(MKDIR_P) $(TOOLDIR)
553 554 555 556 557 558 559
	$(INSTALL) bin/why3config.@OCAMLBEST@  $(TOOLDIR)/why3config$(EXE)
	$(INSTALL) bin/why3execute.@OCAMLBEST@ $(TOOLDIR)/why3execute$(EXE)
	$(INSTALL) bin/why3extract.@OCAMLBEST@ $(TOOLDIR)/why3extract$(EXE)
	$(INSTALL) bin/why3prove.@OCAMLBEST@   $(TOOLDIR)/why3prove$(EXE)
	$(INSTALL) bin/why3realize.@OCAMLBEST@ $(TOOLDIR)/why3realize$(EXE)
	$(INSTALL) bin/why3replay.@OCAMLBEST@  $(TOOLDIR)/why3replay$(EXE)
	$(INSTALL) bin/why3wc.@OCAMLBEST@      $(TOOLDIR)/why3wc$(EXE)
560 561

install_local:: bin/why3 $(addprefix bin/,$(TOOLS_BIN))
562

563
bin/%:	bin/%.@OCAMLBEST@
564
	ln -sf $(notdir $<) $@
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
565

566
install_local:: share/drivers share/stdlib
567 568 569 570

share/drivers:
	ln -snf ../drivers share/drivers

571 572
share/stdlib:
	ln -snf ../stdlib share/stdlib
573

574
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
575
-include $(TOOLSDEP)
576 577
endif

578
depend: $(TOOLSDEP)
579

580 581 582
CLEANDIRS += src/tools
GENERATED += $(TOOLSGENERATED)

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
583
clean::
584
	rm -f bin/why3*
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
585

586 587 588
##############
# test targets
##############
589

590 591
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
592

593 594
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
595

596 597
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
598

599 600
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
601

602
%.type: %.mlw bin/why3ide.opt
603
	bin/why3.opt --type-only $*.mlw
604

605 606 607 608
##############
# Why3server #
##############

609
SERVER_MODULES := logging arraylist options queue readbuf request \
610
		  proc writebuf server-unix server-win
611 612 613

CPULIM_MODULES := cpulimit-unix cpulimit-win

Guillaume Melquiond's avatar
Guillaume Melquiond committed
614
SERVER_O := $(SERVER_MODULES:%=src/server/%.o)
615

616
CPULIM_O := $(CPULIM_MODULES:%=src/server/%.o)
617

618 619
TOOLS = lib/why3server$(EXE) lib/why3cpulimit$(EXE)

620
all: $(TOOLS)
621

622
lib/why3server$(EXE): $(SERVER_O)
623 624 625 626
	$(CC) -Wall -o $@ $^

lib/why3cpulimit$(EXE): $(CPULIM_O)
	$(CC) -Wall -o $@ $^
627

628
%.o: %.c
629
	$(CC) -Wall -O -g -o $@ -c $<
630

631 632 633 634 635
uninstall-bin::
	rm -f $(LIBDIR)/why3/why3server$(EXE) $(LIBDIR)/why3/why3cpulimit$(EXE)
	rm -f $(LIBDIR)/why3/why3-call-pvs

install-bin::
636 637 638 639
	$(MKDIR_P) $(LIBDIR)/why3
	$(INSTALL) lib/why3server$(EXE) $(LIBDIR)/why3/why3server$(EXE)
	$(INSTALL) lib/why3cpulimit$(EXE) $(LIBDIR)/why3/why3cpulimit$(EXE)
	$(INSTALL) lib/why3-call-pvs $(LIBDIR)/why3/why3-call-pvs
640 641

clean::
642
	rm -f $(SERVER_O) $(CPULIM_O) $(TOOLS)
643

644 645 646 647
##########
# gallery
##########

648
# we export exactly the programs that have a why3session.xml file
649 650 651

.PHONY: gallery

652 653 654 655 656
gallery:: gallery-simple gallery-subs

.PHONY: gallery-simple

gallery-simple::
657
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
Andrei Paskevich's avatar
Andrei Paskevich committed
658
	@for x in examples/*/why3session.xml ; do \
659 660
	  d=`dirname $$x`; \
	  f=`basename $$d`; \
661 662
	  echo "exporting $$f"; \
	  mkdir -p $(GALLERYDIR)/$$f; \
663 664
	  WHY3CONFIG="" bin/why3session.@OCAMLBEST@ html $$x -o $(GALLERYDIR)/$$f; \
	  cp examples/$$f.mlw $(GALLERYDIR)/$$f/; \
Andrei Paskevich's avatar
Andrei Paskevich committed
665
	  cd examples/; \
666 667
	  rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	  zip -q -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f; \
668
	  cd ..; \
669
	done
670

671 672
.PHONY: gallery-subs

673
GALLERYSUBS=WP_revisited verifythis_2016_matrix_multiplication avl double_wp prover multiprecision
674 675

gallery-subs::
676
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
677 678
	@for d in $(GALLERYSUBS) ; do \
	  echo "exporting examples/$$d"; \
679
	  mkdir -p $(GALLERYDIR)/$$d; \
680
	  cd examples/$$d; \
681
	  WHY3CONFIG="" ../../bin/why3doc.@OCAMLBEST@ -L ../../stdlib -L . --stdlib-url http://why3.lri.fr/stdlib/ --debug ignore_unused_vars *.mlw -o $(GALLERYDIR)/$$d; \
682
	  cd ..; \
683
	  rm -f $(GALLERYDIR)/$$d/$$d.zip; \
684
	  git archive --format=zip -o $(GALLERYDIR)/$$d/$$d.zip HEAD $$d; \
685 686 687 688
	  cd ..; \
	done


689 690 691 692 693 694
%-gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
	x=$*/why3session.xml; \
	d=`dirname $$x`; \
	f=`basename $$d`; \
	echo "exporting $$f"; \
695
	rm -f $$d/*.bak; \
696
	mkdir -p $(GALLERYDIR)/$$f; \
697
	WHY3CONFIG="" bin/why3session.@OCAMLBEST@ html $$d -o $(GALLERYDIR)/$$f; \
698 699
	if test -f examples/$$f.mlw; then cp examples/$$f.mlw $(GALLERYDIR)/$$f/; fi; \
	if test -f examples/$$f.why; then cp examples/$$f.why $(GALLERYDIR)/$$f/; fi; \
700
	cd examples/; \
701 702
	rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	zip -q -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f
703

MARCHE Claude's avatar
MARCHE Claude committed
704 705 706 707 708 709 710 711
########
# XML DTD validation
########

.PHONY: xml-validate

xml-validate:
	@for x in `find examples/ -name why3session.xml`; do \
712
	  xmllint --noout --valid $$x 2>&1 | head -1; \
MARCHE Claude's avatar
MARCHE Claude committed
713 714
	done

715 716 717 718 719
xml-validate-local:
	@for x in `find examples/ -name why3session.xml`; do \
	  xmllint --noout --dtdvalid share/why3session.dtd $$x 2>&1 | head -1; \
	done

MARCHE Claude's avatar
MARCHE Claude committed
720 721 722 723
###############
# IDE
###############

724 725
ifeq (@enable_ide@,yes)

726 727 728
IDEGENERATED = src/ide/gtkcompat.ml

IDE_FILES = gtkcompat gconfig ide_utils why3ide
MARCHE Claude's avatar
MARCHE Claude committed
729 730 731

IDEMODULES = $(addprefix src/ide/, $(IDE_FILES))

732
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
733 734 735
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

736
$(IDEDEP): DEPFLAGS += -I src/ide
737
$(IDECMO) $(IDECMX): INCLUDES += -I src/ide
MARCHE Claude's avatar
MARCHE Claude committed
738

739 740
$(IDEDEP): $(IDEGENERATED)

741
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
742

743 744
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
745

746 747
bin/why3ide.opt bin/why3ide.byte: INCLUDES += @LABLGTKINCLUDE@
bin/why3ide.opt bin/why3ide.byte: EXTLIBS += @LABLGTKLIB@
748
bin/why3ide.byte: BLINKFLAGS += -custom
MARCHE Claude's avatar
MARCHE Claude committed
749

750 751
bin/why3ide.opt: $(WHY3CMXA) src/ide/resetgc.o $(IDECMX)
bin/why3ide.byte: $(WHY3CMA) src/ide/resetgc.o $(IDECMO)
MARCHE Claude's avatar
MARCHE Claude committed
752

753
src/ide/resetgc.o: src/ide/resetgc.c
754 755
	$(SHOW) 'Ocamlc   $<'
	$(HIDE)$(OCAMLC) -c -ccopt "-Wall -o $@" $<
756

MARCHE Claude's avatar
MARCHE Claude committed
757 758
# depend and clean targets

759
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
760
-include $(IDEDEP)
761
endif
MARCHE Claude's avatar
MARCHE Claude committed
762

763
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
764

765
CLEANDIRS += src/ide
MARCHE Claude's avatar
MARCHE Claude committed
766

767 768 769
ide: bin/why3ide.@OCAMLBEST@

uninstall-ide:
770
	rm -f $(TOOLDIR)/why3ide$(EXE)
771
	rm -rf $(DATADIR)/why3/images
Kate's avatar
Kate committed
772

773
uninstall:: uninstall-ide
Kate's avatar
Kate committed
774

775
install-ide:
776
	$(MKDIR_P) $(TOOLDIR)
777
	$(INSTALL) bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
778 779 780 781 782 783 784 785 786 787
	$(MKDIR_P) $(DATADIR)/why3/images
	for i in share/images/*.rc; do \
	     d=`basename $$i .rc`; \
	     $(INSTALL_DATA) $$i $(DATADIR)/why3/images; \
	     $(MKDIR_P) $(DATADIR)/why3/images/$$d; \
	     $(INSTALL_DATA) share/images/$$d/* $(DATADIR)/why3/images/$$d; \
	done
	$(INSTALL_DATA) share/images/*.png $(DATADIR)/why3/images

install:: install-ide
788

789
install_local:: bin/why3ide
790

791 792 793 794 795 796
ifeq (@GTKVERSION@,2)
src/ide/gtkcompat.ml: config.status src/ide/gtkcompat2.ml
	cp src/ide/gtkcompat2.ml $@
else
src/ide/gtkcompat.ml: config.status src/ide/gtkcompat3.ml
	cp src/ide/gtkcompat3.ml $@
797
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
798

799 800 801
GENERATED += $(IDEGENERATED)

endif
802

803 804 805 806
###############
# WEBSERV
###############

807
WEBSERV_FILES = wserver why3web
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822

WEBSERVMODULES = $(addprefix src/ide/, $(WEBSERV_FILES))

WEBSERVDEP = $(addsuffix .dep, $(WEBSERVMODULES))
WEBSERVCMO = $(addsuffix .cmo, $(WEBSERVMODULES))
WEBSERVCMX = $(addsuffix .cmx, $(WEBSERVMODULES))

$(WEBSERVDEP): DEPFLAGS += -I src/ide
$(WEBSERVCMO) $(WEBSERVCMX): INCLUDES += -I src/ide

# build targets

byte: bin/why3webserver.byte
opt:  bin/why3webserver.opt

823
bin/why3webserver.opt: $(WHY3CMXA) $(WEBSERVCMX)
824 825 826
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

827
bin/why3webserver.byte: $(WHY3CMA) $(WEBSERVCMO)
828 829 830 831 832 833 834 835 836 837 838 839 840
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) -custom $^

# depend and clean targets

ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
-include $(WEBSERVDEP)
endif

depend: $(WEBSERVDEP)

CLEANDIRS += src/ide

841 842
uninstall-bin::
	rm -f $(TOOLDIR)/why3webserver$(EXE)
843

844 845
install-bin::
	$(MKDIR_P) $(TOOLDIR)
846 847 848 849 850
	$(INSTALL) bin/why3webserver.@OCAMLBEST@ $(TOOLDIR)/why3webserver$(EXE)

install_local:: bin/why3webserver


851 852 853 854
###############
# Session
###############

855
SESSION_FILES = why3session_lib why3session_info \
856
		why3session_html why3session_latex why3session_update \
857
		why3session_main
858
# TODO: why3session_copy why3session_rm why3session_csv why3session_run
859
#       why3session_output
860 861 862

SESSIONMODULES = $(addprefix src/why3session/, $(SESSION_FILES))

863
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
864 865 866
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

867
$(SESSIONDEP): DEPFLAGS += -I src/why3session
868 869 870 871 872 873 874
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

byte: bin/why3session.byte
opt:  bin/why3session.opt

875 876
bin/why3session.opt: $(WHY3CMXA) $(SESSIONCMX)
bin/why3session.byte: $(WHY3CMA) $(SESSIONCMO)
877 878 879

# depend and clean targets

880
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
881
-include $(SESSIONDEP)
882
endif
883

884
depend: $(SESSIONDEP)
885

886
CLEANDIRS += src/why3session
887

888 889
uninstall-bin::
	rm -f $(TOOLDIR)/why3session$(EXE)
Kate's avatar
Kate committed
890

891 892
install-bin::
	$(MKDIR_P) $(TOOLDIR)
893
	$(INSTALL) bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
894

895
install_local:: bin/why3session
896

MARCHE Claude's avatar
MARCHE Claude committed
897 898 899 900
###############
# Why3 Shell
###############

901
SHELL_FILES = unix_scheduler why3shell
MARCHE Claude's avatar
MARCHE Claude committed
902

903
SHELLMODULES = $(addprefix src/tools/, $(SHELL_FILES))
MARCHE Claude's avatar
MARCHE Claude committed
904 905 906 907 908

SHELLDEP = $(addsuffix .dep, $(SHELLMODULES))
SHELLCMO = $(addsuffix .cmo, $(SHELLMODULES))
SHELLCMX = $(addsuffix .cmx, $(SHELLMODULES))

909 910
$(SHELLDEP): DEPFLAGS += -I src/tools
$(SHELLCMO) $(SHELLCMX): INCLUDES += -I src/tools
MARCHE Claude's avatar
MARCHE Claude committed
911 912 913 914 915 916

# build targets

byte: bin/why3shell.byte
opt:  bin/why3shell.opt

917
bin/why3shell.opt: $(WHY3CMXA) $(SHELLCMX)
MARCHE Claude's avatar
MARCHE Claude committed
918 919 920
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

921
bin/why3shell.byte: $(WHY3CMA) $(SHELLCMO)
MARCHE Claude's avatar
MARCHE Claude committed
922 923 924 925 926 927 928 929 930 931 932
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

# depend and clean targets

ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
-include $(SHELLDEP)
endif

depend: $(SHELLDEP)

933 934
uninstall-bin::
	rm -f $(TOOLDIR)/why3shell$(EXE)
MARCHE Claude's avatar
MARCHE Claude committed
935

936 937
install-bin::
	$(MKDIR_P) $(TOOLDIR)
MARCHE Claude's avatar
MARCHE Claude committed
938 939 940 941
	$(INSTALL) bin/why3shell.@OCAMLBEST@ $(TOOLDIR)/why3shell$(EXE)

install_local:: bin/why3shell

942 943 944 945
####################
# Coq realizations
####################

946
COQVERSIONSPECIFIC=
947 948 949 950 951 952 953 954 955 956 957 958 959

COQVERSIONSPECIFICTARGETS=$(addprefix lib/coq/, $(COQVERSIONSPECIFIC))
COQVERSIONSPECIFICSOURCES=$(addsuffix .@coq_compat_version@, $(COQVERSIONSPECIFICTARGETS))

$(COQVERSIONSPECIFICTARGETS): $(COQVERSIONSPECIFICSOURCES)
	for i in $(COQVERSIONSPECIFIC); do \
		cp lib/coq/$$i.@coq_compat_version@ lib/coq/$$i ; \
	done

clean::
	rm -f $(COQVERSIONSPECIFICTARGETS)


960
COQLIBS_INT_FILES = Abs ComputerDivision Div2 EuclideanDivision Int MinMax Power NumOf
961 962
COQLIBS_INT_ALL_FILES = Exponentiation $(COQLIBS_INT_FILES)
COQLIBS_INT = $(addprefix lib/coq/int/, $(COQLIBS_INT_ALL_FILES))
963

964 965 966
COQLIBS_BOOL_FILES = Bool
COQLIBS_BOOL = $(addprefix lib/coq/bool/, $(COQLIBS_BOOL_FILES))

967
ifeq (@enable_coq_fp_libs@,yes)
968
COQLIBS_REAL_FILES = Abs ExpLog FromInt MinMax PowerInt PowerReal Real RealInfix Square Trigonometry Truncate
969 970 971
else
COQLIBS_REAL_FILES = Abs ExpLog FromInt MinMax PowerInt PowerReal Real RealInfix Square Trigonometry
endif
972 973
COQLIBS_REAL = $(addprefix lib/coq/real/, $(COQLIBS_REAL_FILES))

974
COQLIBS_NUMBER_FILES = Divisibility Gcd Parity Prime Coprime
975 976
COQLIBS_NUMBER = $(addprefix lib/coq/number/, $(COQLIBS_NUMBER_FILES))

977
COQLIBS_SET_FILES = Set Cardinal Fset FsetInduction FsetInt FsetSum SetApp SetAppInt SetImp SetImpInt
978 979
COQLIBS_SET = $(addprefix lib/coq/set/, $(COQLIBS_SET_FILES))

MARCHE Claude's avatar
MARCHE Claude committed
980
COQLIBS_MAP_FILES = Map Const Occ MapPermut MapInjection
981 982
COQLIBS_MAP = $(addprefix lib/coq/map/, $(COQLIBS_MAP_FILES))

983
COQLIBS_LIST_FILES = List Length Mem Nth NthLength HdTl NthHdTl Append NthLengthAppend Reverse HdTlNoOpt NthNoOpt RevAppend Combine Distinct NumOcc Permut
984 985 986 987 988
COQLIBS_LIST = $(addprefix lib/coq/list/, $(COQLIBS_LIST_FILES))

COQLIBS_OPTION_FILES = Option
COQLIBS_OPTION = $(addprefix lib/coq/option/, $(COQLIBS_OPTION_FILES))

989 990 991
COQLIBS_BV_FILES = Pow2int BV_Gen
COQLIBS_BV = $(addprefix lib/coq/bv/, $(COQLIBS_BV_FILES))

992
ifeq (@enable_coq_fp_libs@,yes)
993
COQLIBS_FP_FILES = Rounding SingleFormat Single DoubleFormat Double
994 995
COQLIBS_FP_ALL_FILES = GenFloat $(COQLIBS_FP_FILES)
COQLIBS_FP = $(addprefix lib/coq/floating_point/, $(COQLIBS_FP_ALL_FILES))
996

997
COQLIBS_IEEEFLOAT_FILES = RoundingMode GenericFloat Float32 Float64
998
COQLIBS_IEEEFLOAT = $(addprefix lib/coq/ieee_float/, $(COQLIBS_IEEEFLOAT_FILES))
999
endif
1000

1001
COQLIBS_FOR_DRIVERS_FILES = ComputerOfEuclideanDivision
1002
COQLIBS_FOR_DRIVERS = $(addprefix lib/coq/for_drivers/, $(COQLIBS_FOR_DRIVERS_FILES))
1003

1004
COQLIBS_FILES = lib/coq/BuiltIn lib/coq/HighOrd $(COQLIBS_INT) $(COQLIBS_BOOL) $(COQLIBS_REAL) $(COQLIBS_NUMBER) $(COQLIBS_SET) $(COQLIBS_MAP) $(COQLIBS_LIST) $(COQLIBS_OPTION) $(COQLIBS_FP)  $(COQLIBS_BV) $(COQLIBS_IEEEFLOAT) $(COQLIBS_FOR_DRIVERS)
1005

1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017
%.vo: %.v
	$(SHOW) 'Coqc     $<'
	$(HIDE)$(COQC) -R lib/coq Why3 $<

%.vd: %.v
	$(SHOW) 'Coqdep   $<'
	$(HIDE)$(COQDEP) -R lib/coq Why3 $< $(TOTARGET)

COQV  = $(addsuffix .v,  $(COQLIBS_FILES))
COQVO = $(addsuffix .vo, $(COQLIBS_FILES))
COQVD = $(addsuffix .vd, $(COQLIBS_FILES))

1018
coq: $(COQVO) drivers/coq-realizations.aux lib/coq/version
1019 1020

clean-coq:
1021
	rm -f $(COQVO) $(COQVD) $(addsuffix .glob, $(COQLIBS_FILES)) lib/coq/version
1022 1023

clean:: clean-coq
1024

1025
drivers/coq-realizations.aux: Makefile
1026 1027
	$(SHOW) 'Generate $@'
	$(HIDE)(echo "(* generated automatically at compilation time *)"; \
Andrei Paskevich's avatar
Andrei Paskevich committed
1028
	echo 'theory BuiltIn meta "realized_theory" "BuiltIn", "" end'; \
1029
	echo 'theory HighOrd meta "realized_theory" "HighOrd", "" end'; \
Andrei Paskevich's avatar
Andrei Paskevich committed
1030
	for f in $(COQLIBS_INT_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
1031
	echo 'theory int.'"$$f"' meta "realized_theory" "int.'"$$f"'", "" end'; done; \
1032 1033
	for f in $(COQLIBS_BOOL_FILES); do \
	echo 'theory bool.'"$$f"' meta "realized_theory" "bool.'"$$f"'", "" end'; done; \
Andrei Paskevich's avatar
Andrei Paskevich committed
1034
	for f in $(COQLIBS_REAL_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
1035
	echo 'theory real.'"$$f"' meta "realized_theory" "real.'"$$f"'", "" end'; done; \
1036
	for f in $(COQLIBS_NUMBER_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
1037
	echo 'theory number.'"$$f"' meta "realized_theory" "number.'"$$f"'", "" end'; done; \
1038
	for f in $(COQLIBS_SET_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
1039
	echo 'theory set.'"$$f"' meta "realized_theory" "set.'"$$f"'", "" end'; done; \
1040 1041
	for f in $(COQLIBS_MAP_FILES); do \
	echo 'theory map.'"$$f"' meta "realized_theory" "map.'"$$f"'", "" end'; done; \
1042 1043 1044 1045
	for f in $(COQLIBS_LIST_FILES); do \
	echo 'theory list.'"$$f"' meta "realized_theory" "list.'"$$f"'", "" end'; done; \
	for f in $(COQLIBS_OPTION_FILES); do \
	echo 'theory option.'"$$f"' meta "realized_theory" "option.'"$$f"'", "" end'; done; \
1046 1047
	for f in $(COQLIBS_BV_FILES); do \
	echo 'theory bv.'"$$f"' meta "realized_theory" "bv.'"$$f"'", "" end'; done; \
1048 1049
	for f in $(COQLIBS_IEEEFLOAT_FILES); do \
	echo 'theory ieee_float.'"$$f"' meta "realized_theory" "ieee_float.'"$$f"'", "" end'; done; \
Andrei Paskevich's avatar
Andrei Paskevich committed
1050
	for f in $(COQLIBS_FP_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
1051
	echo 'theory floating_point.'"$$f"' meta "realized_theory" "floating_point.'"$$f"'", "" end'; done; \
1052 1053
	for f in $(COQLIBS_FOR_DRIVERS_FILES); do \
	echo 'theory for_drivers.'"$$f"' meta "realized_theory" "for_drivers.'"$$f"'", "" end'; done; \
1054
	) > $@
1055

1056
update-coq: update-coq-int update-coq-bool update-coq-real update-coq-number update-coq-set update-coq-map update-coq-list update-coq-option update-coq-fp update-coq-bv update-coq-ieee_float update-coq-for-drivers
1057

1058
update-coq-int: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/int.mlw
1059
	for f in $(COQLIBS_INT_ALL_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L stdlib -D drivers/coq-realize.drv -T int.$$f -o $(GENERATED_PREFIX_COQ)/int/; done
1060

1061
update-coq-bool: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/bool.mlw
1062
	for f in $(COQLIBS_BOOL_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L stdlib -D drivers/coq-realize.drv -T bool.$$f -o $(GENERATED_PREFIX_COQ)/bool/; done
1063

1064
update-coq-real: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/real.mlw
1065
	for f in $(COQLIBS_REAL_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L stdlib -D drivers/coq-realize.drv -T real.$$f -o $(GENERATED_PREFIX_COQ)/real/; done
1066

1067
update-coq-number: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/number.mlw
1068
	for f in $(COQLIBS_NUMBER_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L stdlib -D drivers/coq-realize.drv -T number.$$f -o $(GENERATED_PREFIX_COQ)/number/; done
1069

1070
update-coq-set: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/set.mlw
1071
	for f in $(COQLIBS_SET_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L stdlib -D drivers/coq-realize.drv -T set.$$f -o $(GENERATED_PREFIX_COQ)/set/; done
1072

1073
update-coq-map: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/map.mlw
1074
	for f in $(COQLIBS_MAP_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L stdlib -D drivers/coq-realize.drv -T map.$$f -o $(GENERATED_PREFIX_COQ)/map/; done
1075

1076
update-coq-list: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/list.mlw
1077
	for f in $(COQLIBS_LIST_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L stdlib -D drivers/coq-realize.drv -T list.$$f -o $(GENERATED_PREFIX_COQ)/list/; done
1078

1079
update-coq-option: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/option.mlw
1080
	for f in $(COQLIBS_OPTION_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L stdlib -D drivers/coq-realize.drv -T option.$$f -o $(GENERATED_PREFIX_COQ)/option/; done
1081

1082
update-coq-bv: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/bv.mlw
1083
	for f in $(COQLIBS_BV_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L stdlib -D drivers/coq-realize.drv -T bv.$$f -o $(GENERATED_PREFIX_COQ)/bv/; done
1084

1085 1086
update-coq-for-drivers: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/for_drivers.mlw
	for f in $(COQLIBS_FOR_DRIVERS_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L stdlib -D drivers/coq-realize.drv -T for_drivers.$$f -o $(GENERATED_PREFIX_COQ)/for_drivers/; done
1087