Makefile.in 74.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-2018   --   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 23
.DELETE_ON_ERROR:

24
# install the binaries
25
DESTDIR =
26

27
prefix	    = @prefix@
28 29 30 31 32
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@

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

Andrei Paskevich's avatar
Andrei Paskevich committed
37
# OS specific stuff
38
EXE   = @EXE@
39 40

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

60 61 62 63 64
DEPFLAGS = -slash

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

70
RUBBER = @RUBBER@
71
HEVEA = @HEVEA@
72
HACHA = @HACHA@
73
EMACS = @EMACS@
74

75
#PSVIEWER  = @PSVIEWER@
Andrei Paskevich's avatar
Andrei Paskevich committed
76
#PDFVIEWER = @PDFVIEWER@
77

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

# 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.
89
#   50   Unexpected documentation comment.
90 91 92
#   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.
93 94 95 96 97
# - fatal:
#   5    Partially applied function: expression whose result has function
#        type and is ignored.
#   48   Implicit elimination of optional arguments.

98
WARNINGS = A-4-9-41-44-45-50-52@5@48
99

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

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

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

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

113 114
# external libraries common to all binaries

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

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

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

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

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

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

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

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

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

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

156 157 158 159
.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
160
.PHONY: ide install-ide uninstall-ide
161 162
.PHONY: coq install-coq uninstall-coq clean-coq
.PHONY: pvs install-pvs uninstall-pvs clean-pvs
163
.PHONY: install-isabelle
164
.PHONY: plugins plugins.byte plugins.opt
165

166 167 168 169
CLEANDIRS =
CLEANLIBS =
GENERATED =

170 171 172
##############
# Why3 library
##############
173

174
LIBGENERATED = src/util/config.ml \
175 176 177 178
	       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 \
179
	       src/parser/parser.mli src/parser/parser.ml \
180
	       src/parser/parser_messages.ml \
181
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
182
	       src/driver/driver_lexer.ml \
183 184
	       src/driver/parse_smtv2_model_parser.mli src/driver/parse_smtv2_model_parser.ml \
	       src/driver/parse_smtv2_model_lexer.ml \
185
	       src/session/compress.ml src/session/xml.ml \
186
	       src/session/strategy_parser.ml \
187
	       lib/ocaml/why3__BigInt_compat.ml
188

189
LIB_UTIL = config bigInt util opt lists strings \
190
	   pp extmap extset exthtbl weakhtbl \
191
	   hashcons wstdlib exn_printer \
192
	   json_base json_parser json_lexer \
193
	   debug loc lexlib print_tree \
194
	   cmdline warning sysutil rc plugin bigInt number pqueue
195

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

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

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

209
LIB_PARSER = ptree glob typing parser_messages parser typing report lexer
210

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

Sylvain Dailler's avatar
Sylvain Dailler committed
231
LIB_PRINTER = cntexmp_printer alt_ergo why3printer smtv1 smtv2 coq\
232
	      pvs isabelle \
233
	      simplify gappa cvc3 yices mathematica
234

235 236 237
LIB_SESSION = compress xml termcode session_itp \
              strategy strategy_parser controller_itp \
	      server_utils itp_communication \
238
	      itp_server json_util
239

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

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

252
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
253 254
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
255

256
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
257
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
258
$(LIBCMX): OFLAGS += -for-pack Why3
259

260 261
$(LIBDEP): $(LIBGENERATED)

262 263 264
# Zarith

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

272 273 274 275 276 277 278 279 280 281
# 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

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
.PHONY: initialize_messages

initialize_messages: src/parser/parser.mly
	$(MENHIR) --explain --strict src/parser/parser.mly --list-errors > src/parser/handcrafted.messages

src/parser/parser_messages.ml: src/parser/parser.mly src/parser/handcrafted.messages
	$(MENHIR) --explain --strict src/parser/parser.mly --update-errors \
src/parser/handcrafted.messages > src/parser/handcrafted.messages.temp;
# If the update fails, the exit code is 0 so we also try to compile-errors directly
# before replacing handcrafted.messages. If the following line fails, exit code
# 1 is returned stopping the command. And empty file parser_messages.ml is
# deleted by .DELETE_ON_ERROR. This behavior ensures that second run of make
# will not continue with a fake parser_messages.ml.
	$(MENHIR) --explain --strict src/parser/parser.mly --compile-errors \
src/parser/handcrafted.messages.temp > src/parser/parser_messages.ml;
	if cmp -s src/parser/handcrafted.messages.temp src/parser/handcrafted.messages; then \
	echo "parser_messages.ml OK"; \
	else \
	echo "Regenerating handcrafted.messages"; \
	rm -f src/parser/parser_messages.ml; \
	cp src/parser/handcrafted.messages.temp src/parser/handcrafted.messages; \
	rm -f src/parser/handcrafted.messages.temp; \
	fi

clean ::
	rm -f src/parser/handcrafted.messages.temp

309 310
# hide deprecated warnings for strings

311 312
src/util/strings.cmo: WARNINGS:=$(WARNINGS)-3
src/util/strings.cmx: WARNINGS:=$(WARNINGS)-3
313

314 315 316
# compiler plugins

ifeq (@enable_compiler_plugins@,yes)
317
src/util/debug_optim.cmxs: src/util/debug_optim.ml
318
	$(SHOW) 'Linking $@'
319
	$(HIDE)$(OCAMLOPT) -I @COMPILERLIBS@ -shared src/util/debug_optim.ml -o $@
320 321 322 323
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
324 325
endif

326
# build targets
327

328
byte: lib/why3/why3.cma
329
opt:  lib/why3/why3.cmxa lib/why3/why3.cmxs
330

331 332
lib/why3/why3.cma: lib/why3/why3.cmo
lib/why3/why3.cmxa: lib/why3/why3.cmx
333
lib/why3/why3.cmxs: lib/why3/why3.cmx
334

335
lib/why3/why3.cmo: $(LIBCMO)
336 337
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $^
338

339
lib/why3/why3.cmx: $(LIBCMX) lib/why3/why3.cmo
340
	$(SHOW) 'Linking  $@'
341
	$(HIDE)$(OCAMLOPT) $(OFLAGS) $(CMIHACK) -pack -o $@ $(filter %.cmx, $^)
342

343
# clean and depend
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
344

345
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
346
-include $(LIBDEP)
347
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
348

349
depend: $(LIBDEP)
350

351
CLEANDIRS += src $(addprefix src/, $(LIBDIRS))
352
CLEANLIBS += lib/why3/why3
353
GENERATED += $(LIBGENERATED)
354

355 356 357
###############
# installation
###############
358

359
uninstall-data::
MARCHE Claude's avatar
MARCHE Claude committed
360 361
	rm -rf $(DATADIR)/why3

362
install-data::
363 364
	$(MKDIR_P) $(DATADIR)/why3
	$(MKDIR_P) $(DATADIR)/why3/vim
365 366
	$(MKDIR_P) $(DATADIR)/why3/vim/ftdetect
	$(MKDIR_P) $(DATADIR)/why3/vim/syntax
367
	$(MKDIR_P) $(DATADIR)/why3/lang
368 369
	$(MKDIR_P) $(DATADIR)/why3/stdlib
	$(MKDIR_P) $(DATADIR)/why3/stdlib/mach
370
	$(MKDIR_P) $(DATADIR)/why3/drivers
371
	$(INSTALL_DATA) stdlib/*.mlw $(DATADIR)/why3/stdlib
372
	$(INSTALL_DATA) stdlib/mach/*.mlw $(DATADIR)/why3/stdlib/mach
373 374 375 376 377
	$(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
378 379
	$(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
380
	$(INSTALL_DATA) share/lang/why3.lang $(DATADIR)/why3/lang/why3.lang
381

382 383
ifeq (@enable_local@,yes)
else
384 385 386 387
install:: install-bin install-data

uninstall:: uninstall-bin uninstall-data
	rm -rf $(LIBDIR)/why3
388 389
endif

390 391 392 393
uninstall-lib:
	if test -d $(OCAMLINSTALLLIB) -a -w $(OCAMLINSTALLLIB); then \
	  rm -rf $(OCAMLINSTALLLIB)/why3; \
	fi
MARCHE Claude's avatar
MARCHE Claude committed
394

395
uninstall:: uninstall-lib
Kate's avatar
Kate committed
396

397 398 399 400
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
401

402 403 404 405 406 407 408
##################
# Why3 emacs mode
##################

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

409
uninstall-emacs:
Kate's avatar
Kate committed
410 411 412
	rm -f $(DATADIR)/emacs/site-lisp/why3.el
	rm -f $(DATADIR)/emacs/site-lisp/why3.elc

413 414 415
uninstall:: uninstall-emacs

install-emacs:
416
	$(MKDIR_P) $(DATADIR)/emacs/site-lisp/
417
	$(INSTALL_DATA) share/emacs/why3.el $(DATADIR)/emacs/site-lisp/why3.el
418
ifeq (@enable_emacs_compilation@,yes)
419
	$(INSTALL_DATA) share/emacs/why3.elc $(DATADIR)/emacs/site-lisp/why3.elc
Kate's avatar
Kate committed
420 421
endif

422 423
install:: install-emacs

424
ifeq (@enable_emacs_compilation@,yes)
425
all: share/emacs/why3.elc
426 427
endif

Kate's avatar
Kate committed
428

429
##################
430
# Why3 plugins
431 432
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
433
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
434
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
435 436
		plugins/python/py_lexer.ml \
		plugins/python/py_parser.ml plugins/python/py_parser.mli \
437
		plugins/parser/dimacs.ml \
438

439
PLUG_PARSER = genequlin dimacs
440
PLUG_PRINTER =
441
PLUG_TRANSFORM =
442
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
443
PLUG_PYTHON = py_ast py_parser py_lexer py_main
444

445
PLUGINS = genequlin dimacs tptp python
446

447
TPTPMODULES = $(addprefix plugins/tptp/, $(PLUG_TPTP))
448
PYTHONMODULES = $(addprefix plugins/python/, $(PLUG_PYTHON))
Andrei Paskevich's avatar
Andrei Paskevich committed
449

450 451
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
452

453 454 455
PYTHONCMO = $(addsuffix .cmo, $(PYTHONMODULES))
PYTHONCMX = $(addsuffix .cmx, $(PYTHONMODULES))

456 457 458 459 460 461 462 463 464 465
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

466 467
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
468
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
469
	      $(TPTPMODULES) $(PYTHONMODULES)
470

471
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
472 473 474
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

475
PLUGDIRS = parser printer transform tptp python
476 477
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

478
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
479 480
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

481 482
$(PLUGDEP): $(PLUGGENERATED)

483 484
LIBPLUGCMO =  $(PLUGINS:%=lib/plugins/%.cmo)
LIBPLUGCMXS = $(PLUGINS:%=lib/plugins/%.cmxs)
485 486 487

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

489 490
lib/plugins:
	mkdir lib/plugins
491

492
lib/plugins/%.cmxs: | lib/plugins
493
	$(SHOW) 'Linking  $@'
494
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -shared -o $@ $^
495

496
lib/plugins/%.cmo: | lib/plugins
497
	$(SHOW) 'Linking  $@'
498
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $^
499

500 501
lib/plugins/%.cmxs: plugins/parser/%.cmx
lib/plugins/%.cmo: plugins/parser/%.cmo
502 503 504 505
lib/plugins/%.cmxs: plugins/printer/%.cmx
lib/plugins/%.cmo: plugins/printer/%.cmo
lib/plugins/%.cmxs: plugins/transform/%.cmx
lib/plugins/%.cmo: plugins/transform/%.cmo
506 507
lib/plugins/tptp.cmxs: $(TPTPCMX)
lib/plugins/tptp.cmo: $(TPTPCMO)
508 509
lib/plugins/python.cmxs: $(PYTHONCMX)
lib/plugins/python.cmo: $(PYTHONCMO)
510

511 512
# depend and clean targets

513
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
514
-include $(PLUGDEP)
515 516
endif

517
depend: $(PLUGDEP)
518

519 520
CLEANDIRS += plugins $(addprefix plugins/, $(PLUGDIRS)) lib/plugins
GENERATED += $(PLUGGENERATED)
521

522 523 524 525 526
uninstall-bin::
	rm -f $(PLUGINS:%=$(LIBDIR)/why3/plugins/%.cmo)
	rm -f $(PLUGINS:%=$(LIBDIR)/why3/plugins/%.cmxs)

install-bin::
527 528
	$(MKDIR_P) $(LIBDIR)/why3/plugins
	$(INSTALL_DATA) $(wildcard $(LIBPLUGCMO) $(LIBPLUGCMXS)) $(LIBDIR)/why3/plugins
529

530 531 532 533
###############
# Why3 commands
###############

534 535 536 537 538
TOOLSGENERATED = src/tools/why3wc.ml

TOOLS_BIN = why3config why3execute why3extract why3prove \
	    why3realize why3replay why3wc

539
TOOLS_FILES = main $(TOOLS_BIN)
540 541 542 543 544 545 546 547 548 549

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

550 551
$(TOOLSDEP): $(TOOLSGENERATED)

552 553 554
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

555 556 557
bin:
	mkdir bin

558 559 560 561 562 563 564 565 566 567 568 569 570 571
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
572 573 574
bin/why3wc.opt: src/tools/why3wc.cmx
bin/why3wc.byte: src/tools/why3wc.cmo

575 576 577
uninstall-bin::
	rm -f $(BINDIR)/why3$(EXE)
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE))
Kate's avatar
Kate committed
578

579 580
install-bin::
	$(MKDIR_P) $(BINDIR)
581
	$(INSTALL) bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
582
	$(MKDIR_P) $(TOOLDIR)
583 584 585 586 587 588 589
	$(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)
590 591

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

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

596
install_local:: share/drivers share/stdlib
597 598 599 600

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

601 602
share/stdlib:
	ln -snf ../stdlib share/stdlib
603

604
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
605
-include $(TOOLSDEP)
606 607
endif

608
depend: $(TOOLSDEP)
609

610 611 612
CLEANDIRS += src/tools
GENERATED += $(TOOLSGENERATED)

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
613
clean::
614
	rm -f bin/why3*
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
615

616 617 618
##############
# test targets
##############
619

620 621
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
622

623 624
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
625

626 627
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
628

629 630
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
631

632
%.type: %.mlw bin/why3ide.opt
633
	bin/why3.opt --type-only $*.mlw
634

635 636 637 638
##############
# Why3server #
##############

639 640 641 642 643
SERVER_MODULES := logging arraylist options queue readbuf request \
		  writebuf server-unix server-win

CPULIM_MODULES := cpulimit-unix cpulimit-win

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

646
CPULIM_O := $(CPULIM_MODULES:%=src/server/%.o)
647

648 649
TOOLS = lib/why3server$(EXE) lib/why3cpulimit$(EXE)

650
all: $(TOOLS)
651

652
lib/why3server$(EXE): $(SERVER_O)
653 654 655 656
	$(CC) -Wall -o $@ $^

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

658
%.o: %.c
659
	$(CC) -Wall -O -g -o $@ -c $<
660

661 662 663 664 665
uninstall-bin::
	rm -f $(LIBDIR)/why3/why3server$(EXE) $(LIBDIR)/why3/why3cpulimit$(EXE)
	rm -f $(LIBDIR)/why3/why3-call-pvs

install-bin::
666 667 668 669
	$(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
670 671

clean::
672
	rm -f $(SERVER_O) $(CPULIM_O) $(TOOLS)
673

674 675 676 677
##########
# gallery
##########

678
# we export exactly the programs that have a why3session.xml file
679 680 681

.PHONY: gallery

682 683 684 685 686
gallery:: gallery-simple gallery-subs

.PHONY: gallery-simple

gallery-simple::
687
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
Andrei Paskevich's avatar
Andrei Paskevich committed
688
	@for x in examples/*/why3session.xml ; do \
689 690
	  d=`dirname $$x`; \
	  f=`basename $$d`; \
691 692
	  echo "exporting $$f"; \
	  mkdir -p $(GALLERYDIR)/$$f; \
693 694
	  WHY3CONFIG="" bin/why3session.@OCAMLBEST@ html $$x -o $(GALLERYDIR)/$$f; \
	  cp examples/$$f.mlw $(GALLERYDIR)/$$f/; \
Andrei Paskevich's avatar
Andrei Paskevich committed
695
	  cd examples/; \
696 697
	  rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	  zip -q -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f; \
698
	  cd ..; \
699
	done
700

701 702
.PHONY: gallery-subs

703
GALLERYSUBS=WP_revisited verifythis_2016_matrix_multiplication avl double_wp prover multiprecision
704 705

gallery-subs::
706
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
707 708
	@for d in $(GALLERYSUBS) ; do \
	  echo "exporting examples/$$d"; \
709
	  mkdir -p $(GALLERYDIR)/$$d; \
710
	  cd examples/$$d; \
711
	  WHY3CONFIG="" ../../bin/why3doc.@OCAMLBEST@ -L ../../stdlib -L . --stdlib-url http://why3.lri.fr/stdlib/ --debug ignore_unused_vars *.mlw -o $(GALLERYDIR)/$$d; \
712
	  cd ..; \
713
	  rm -f $(GALLERYDIR)/$$d/$$d.zip; \
714
	  git archive --format=zip -o $(GALLERYDIR)/$$d/$$d.zip HEAD $$d; \
715 716 717 718
	  cd ..; \
	done


719 720 721 722 723 724
%-gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
	x=$*/why3session.xml; \
	d=`dirname $$x`; \
	f=`basename $$d`; \
	echo "exporting $$f"; \
725
	rm -f $$d/*.bak; \
726
	mkdir -p $(GALLERYDIR)/$$f; \
727
	WHY3CONFIG="" bin/why3session.@OCAMLBEST@ html $$d -o $(GALLERYDIR)/$$f; \
728 729
	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; \
730
	cd examples/; \
731 732
	rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	zip -q -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f
733

MARCHE Claude's avatar
MARCHE Claude committed
734 735 736 737 738 739 740 741
########
# XML DTD validation
########

.PHONY: xml-validate

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

745 746 747 748 749
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
750 751 752 753
###############
# IDE
###############

754 755
ifeq (@enable_ide@,yes)

Sylvain Dailler's avatar
Sylvain Dailler committed
756
IDE_FILES = gconfig ide_utils why3ide
MARCHE Claude's avatar
MARCHE Claude committed
757 758 759

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

760
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
761 762 763
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

764
$(IDEDEP): DEPFLAGS += -I src/ide
765
$(IDECMO) $(IDECMX): INCLUDES += -I src/ide
MARCHE Claude's avatar
MARCHE Claude committed
766

767
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
768

769 770
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
771

772
bin/why3ide.opt bin/why3ide.byte: INCLUDES += -I @LABLGTK2LIB@
773
bin/why3ide.opt bin/why3ide.byte: EXTLIBS += lablgtk lablgtksourceview2
774
bin/why3ide.byte: BLINKFLAGS += -custom
MARCHE Claude's avatar
MARCHE Claude committed
775

776 777
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
778

779
src/ide/resetgc.o: src/ide/resetgc.c
780 781
	$(SHOW) 'Ocamlc   $<'
	$(HIDE)$(OCAMLC) -c -ccopt "-Wall -o $@" $<
782

MARCHE Claude's avatar
MARCHE Claude committed
783 784
# depend and clean targets

785
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
786
-include $(IDEDEP)
787
endif
MARCHE Claude's avatar
MARCHE Claude committed
788

789
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
790

791
CLEANDIRS += src/ide
MARCHE Claude's avatar
MARCHE Claude committed
792

793 794 795
ide: bin/why3ide.@OCAMLBEST@

uninstall-ide:
796
	rm -f $(TOOLDIR)/why3ide$(EXE)
797
	rm -rf $(DATADIR)/why3/images
Kate's avatar
Kate committed
798

799
uninstall:: uninstall-ide
Kate's avatar
Kate committed
800

801
install-ide:
802
	$(MKDIR_P) $(TOOLDIR)
803
	$(INSTALL) bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
804 805 806 807 808 809 810 811 812 813
	$(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
814

815
install_local:: bin/why3ide
816

817
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
818

819

820 821 822 823
###############
# WEBSERV
###############

824
WEBSERV_FILES = wserver why3web
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839

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

840
bin/why3webserver.opt: $(WHY3CMXA) $(WEBSERVCMX)
841 842 843
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

844
bin/why3webserver.byte: $(WHY3CMA) $(WEBSERVCMO)
845 846 847 848 849 850 851 852 853 854 855 856 857
	$(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

858 859
uninstall-bin::
	rm -f $(TOOLDIR)/why3webserver$(EXE)
860

861 862
install-bin::
	$(MKDIR_P) $(TOOLDIR)
863 864 865 866 867
	$(INSTALL) bin/why3webserver.@OCAMLBEST@ $(TOOLDIR)/why3webserver$(EXE)

install_local:: bin/why3webserver


868 869 870 871
###############
# Session
###############

872
SESSION_FILES = why3session_lib why3session_info \
873
		why3session_html why3session_latex \
874
		why3session_main
875
# TODO: why3session_copy why3session_rm why3session_csv why3session_run
876
#       why3session_output
877 878 879

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

880
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
881 882 883
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

884
$(SESSIONDEP): DEPFLAGS += -I src/why3session
885 886 887 888 889 890 891
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

892 893
bin/why3session.opt: $(WHY3CMXA) $(SESSIONCMX)
bin/why3session.byte: $(WHY3CMA) $(SESSIONCMO)
894 895 896

# depend and clean targets

897
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
898
-include $(SESSIONDEP)
899
endif
900

901
depend: $(SESSIONDEP)
902

903
CLEANDIRS += src/why3session
904

905 906
uninstall-bin::
	rm -f $(TOOLDIR)/why3session$(EXE)
Kate's avatar
Kate committed
907

908 909
install-bin::
	$(MKDIR_P) $(TOOLDIR)
910
	$(INSTALL) bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
911

912
install_local:: bin/why3session
913

MARCHE Claude's avatar
MARCHE Claude committed
914 915 916 917
###############
# Why3 Shell
###############

918
SHELL_FILES = unix_scheduler why3shell
MARCHE Claude's avatar
MARCHE Claude committed
919

920
SHELLMODULES = $(addprefix src/tools/, $(SHELL_FILES))
MARCHE Claude's avatar
MARCHE Claude committed
921 922 923 924 925

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

926 927
$(SHELLDEP): DEPFLAGS += -I src/tools
$(SHELLCMO) $(SHELLCMX): INCLUDES += -I src/tools
MARCHE Claude's avatar
MARCHE Claude committed
928 929 930 931 932 933

# build targets

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

934
bin/why3shell.opt: $(WHY3CMXA) $(SHELLCMX)
MARCHE Claude's avatar
MARCHE Claude committed
935 936 937
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

938
bin/why3shell.byte: $(WHY3CMA) $(SHELLCMO)
MARCHE Claude's avatar
MARCHE Claude committed
939 940 941 942 943 944 945 946 947 948 949
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

# depend and clean targets

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

depend: $(SHELLDEP)

950 951
uninstall-bin::
	rm -f $(TOOLDIR)/why3shell$(EXE)
MARCHE Claude's avatar
MARCHE Claude committed
952

953 954
install-bin::
	$(MKDIR_P) $(TOOLDIR)
MARCHE Claude's avatar
MARCHE Claude committed
955 956 957 958
	$(INSTALL) bin/why3shell.@OCAMLBEST@ $(TOOLDIR)/why3shell$(EXE)

install_local:: bin/why3shell

959 960 961 962
####################
# Coq realizations
####################

963
COQVERSIONSPECIFIC=
964 965 966 967 968 969 970 971 972 973 974 975 976

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)


977
COQLIBS_INT_FILES = Abs ComputerDivision Div2 EuclideanDivision Int MinMax Power NumOf
978 979
COQLIBS_INT_ALL_FILES = Exponentiation $(COQLIBS_INT_FILES)
COQLIBS_INT = $(addprefix lib/coq/int/, $(COQLIBS_INT_ALL_FILES))
980

981 982 983
COQLIBS_BOOL_FILES = Bool
COQLIBS_BOOL = $(addprefix lib/coq/bool/, $(COQLIBS_BOOL_FILES))

984
ifeq (@enable_coq_fp_libs@,yes)
985
COQLIBS_REAL_FILES = Abs ExpLog FromInt MinMax PowerInt PowerReal Real RealInfix Square Trigonometry Truncate
986 987 988
else
COQLIBS_REAL_FILES = Abs ExpLog FromInt MinMax PowerInt PowerReal Real RealInfix Square Trigonometry
endif
989 990
COQLIBS_REAL = $(addprefix lib/coq/real/, $(COQLIBS_REAL_FILES))

991
COQLIBS_NUMBER_FILES = Divisibility Gcd Parity Prime Coprime
992 993
COQLIBS_NUMBER = $(addprefix lib/coq/number/, $(COQLIBS_NUMBER_FILES))

994 995 996
COQLIBS_SET_FILES = Set
COQLIBS_SET = $(addprefix lib/coq/set/, $(COQLIBS_SET_FILES))

MARCHE Claude's avatar
MARCHE Claude committed
997
COQLIBS_MAP_FILES = Map Const Occ MapPermut MapInjection
998 999
COQLIBS_MAP = $(addprefix lib/coq/map/, $(COQLIBS_MAP_FILES))

1000
COQLIBS_LIST_FILES = List Length Mem Nth NthLength HdTl NthHdTl Append NthLengthAppend Reverse HdTlNoOpt NthNoOpt RevAppend Combine Distinct NumOcc Permut
1001 1002 1003 1004 1005
COQLIBS_LIST = $(addprefix lib/coq/list/, $(COQLIBS_LIST_FILES))

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

1006 1007 1008
COQLIBS_BV_FILES = Pow2int BV_Gen
COQLIBS_BV = $(addprefix lib/coq/bv/, $(COQLIBS_BV_FILES))

1009
ifeq (@enable_coq_fp_libs@,yes)
1010
COQLIBS_FP_FILES = Rounding SingleFormat Single DoubleFormat Double
1011 1012
COQLIBS_FP_ALL_FILES = GenFloat $(COQLIBS_FP_FILES)
COQLIBS_FP = $(addprefix lib/coq/floating_point/, $(COQLIBS_FP_ALL_FILES))
1013

1014
COQLIBS_IEEEFLOAT_FILES = RoundingMode GenericFloat Float32 Float64
1015
COQLIBS_IEEEFLOAT = $(addprefix lib/coq/ieee_float/, $(COQLIBS_IEEEFLOAT_FILES))
1016
endif
1017

1018 1019
COQLIBS_FOR_DRIVERS_FILES = ComputerOfEuclideanDivision

1020
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)
1021

1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033
%.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))

1034
coq: $(COQVO) drivers/coq-realizations.aux lib/coq/version
1035 1036

clean-coq:
1037
	rm -f $(COQVO) $(COQVD) $(addsuffix .glob, $(COQLIBS_FILES)) lib/coq/version
1038 1039

clean:: clean-coq
1040

1041
drivers/coq-realizations.aux: Makefile
1042 1043
	$(SHOW) 'Generate $@'
	$(HIDE)(echo "(* generated automatically at compilation time *)"; \
Andrei Paskevich's avatar
Andrei Paskevich committed
1044
	echo 'theory BuiltIn meta "realized_theory" "BuiltIn", "" end'; \
1045
	echo 'theory HighOrd meta "realized_theory" "HighOrd", "" end'; \
Andrei Paskevich's avatar
Andrei Paskevich committed
1046
	for f in $(COQLIBS_INT_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
1047
	echo 'theory int.'"$$f"' meta "realized_theory" "int.'"$$f"'", "" end'; done; \
1048 1049
	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
1050
	for f in $(COQLIBS_REAL_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
1051
	echo 'theory real.'"$$f"' meta "realized_theory" "real.'"$$f"'", "" end'; done; \
1052
	for f in $(COQLIBS_NUMBER_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
1053
	echo 'theory number.'"$$f"' meta "realized_theory" "number.'"$$f"'", "" end'; done; \
1054
	for f in $(COQLIBS_SET_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
1055
	echo 'theory set.'"$$f"' meta "realized_theory" "set.'"$$f"'", "" end'; done; \
1056 1057
	for f in $(COQLIBS_MAP_FILES); do \
	echo 'theory map.'"$$f"' meta "realized_theory" "map.'"$$f"'", "" end'; done; \
1058 1059 1060 1061
	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; \
1062 1063
	for f in $(COQLIBS_BV_FILES); do \
	echo 'theory bv.'"$$f"' meta "realized_theory" "bv.'"$$f"'", "" end'; done; \
1064 1065
	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
1066
	for f in $(COQLIBS_FP_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
1067
	echo 'theory floating_point.'"$$f"' meta "realized_theory" "floating_point.'"$$f"'", "" end'; done; \
1068 1069
	for f in $(COQLIBS_FOR_DRIVER_FILES); do \
	echo 'theory for_driver.'"$$f"' meta "realized_theory" "for_driver.'"$$f"'", "" end'; done; \
1070
	) > $@
1071

1072
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
1073

1074
update-coq-int: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/int.mlw
1075
	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
1076

1077
update-coq-bool: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/bool.mlw
1078
	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
1079

1080
update-coq-real: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/real.mlw
1081
	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
1082

1083
update-coq-number: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/number.mlw
1084
	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
1085

1086
update-coq-set: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/set.mlw
1087
	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
1088

1089
update-coq-map: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/map.mlw
1090
	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
1091

1092
update-coq-list: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/list.mlw
1093
	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
1094

1095
update-coq-option: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/option.mlw
1096
	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
1097

1098
update-coq-bv: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/bv.mlw
1099
	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
1100

1101 1102 1103
update-coq-for-drivers: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux theories/for_drivers.why
	for f in $(COQLIBS_FOR_DRIVERS_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L theories -D drivers/coq-realize.drv -T for_drivers.$$f -o $(GENERATED_PREFIX_COQ)/for_drivers/; done

1104
update-coq-ieee_float: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/ieee_float.mlw
1105
	for f in $(COQLIBS_IEEEFLOAT_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L stdlib -D drivers/coq-realize.drv -T ieee_float.$$f -o $(GENERATED_PREFIX_COQ)/ieee_float/; done
1106

1107
update-coq-fp: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/floating_point.mlw
1108
	for f in $(COQLIBS_FP_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L stdlib -D drivers/coq-realize.drv -T floating_point.$$f -o $(GENERATED_PREFIX_COQ)/floating_point/; done
1109 1110 1111

ifeq (@enable_coq_libs@,yes)

1112 1113 1114
uninstall-coq:
	rm -rf $(LIBDIR)/why3/coq

1115
install-coq:
1116
	$(MKDIR_P) $(LIBDIR)/why3/coq
1117
	$(INSTALL_DATA) lib/coq/version $(LIBDIR)/why3/coq/
1118 1119 1120 1121 1122