Makefile.in 76.5 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82
ifeq (@LATEX@,rubber)
   LATEXCOMP=rubber --warn all --pdf
   LATEXCLEAN=rubber --pdf --clean
endif

ifeq (@LATEX@,latexmk)
   LATEXCOMP=latexmk --pdf
   LATEXCLEAN=latexmk --pdf -C
endif

ifeq (@LATEX@,pdflatex)
   LATEXCOMP=pdflatex
   LATEXCLEAN=true
endif

83
HEVEA = @HEVEA@
84
HACHA = @HACHA@
85
EMACS = @EMACS@
86

87
#PSVIEWER  = @PSVIEWER@
Andrei Paskevich's avatar
Andrei Paskevich committed
88
#PDFVIEWER = @PDFVIEWER@
89

90
INCLUDES = @WHY3INCLUDE@ @ZIPINCLUDE@ @MENHIRINCLUDE@ @NUMINCLUDE@ @MLMPFRINCLUDE@
91 92 93 94 95 96 97 98 99 100

# 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.
101
#   50   Unexpected documentation comment.
102 103 104
#   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.
105 106 107
# - fatal:
#   5    Partially applied function: expression whose result has function
#        type and is ignored.
108
#   8    Partial match: missing cases in pattern-matching.
Andrei Paskevich's avatar
Andrei Paskevich committed
109
#   48   Implicit elimination of optional arguments.
110

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

113 114
OFLAGS = -w $(WARNINGS) -safe-string -keep-locs -bin-annot -dtypes -g $(INCLUDES)
BFLAGS = -w $(WARNINGS) -safe-string -keep-locs -bin-annot -dtypes -g $(INCLUDES)
115

116 117
OLINKFLAGS = -linkall @MLMPFR_LINK@ $(EXTCMXA)
BLINKFLAGS = -linkall @MLMPFR_LINK@ $(EXTCMA)
118

119
ifeq (@enable_profiling@,yes)
120 121 122
OFLAGS += -g -p
endif

123 124 125
# see http://caml.inria.fr/mantis/view.php?id=4991
CMIHACK = -intf-suffix .cmi

126 127
# external libraries common to all binaries

128
EXTOBJS = menhirLib
129
EXTLIBS = str unix nums dynlink @ZIPLIB@ @MLMPFR@ @WHY3LIB@
130

131 132
EXTCMA	= $(addsuffix .cmo,$(EXTOBJS)) $(addsuffix .cma,$(EXTLIBS))
EXTCMXA = $(addsuffix .cmx,$(EXTOBJS)) $(addsuffix .cmxa,$(EXTLIBS))
133

134 135
INSTALLED_LIB_EXTS = a cma cmx cmi cmxa cmxs
COMPILED_LIB_EXTS = $(INSTALLED_LIB_EXTS) o cmo cmt cmti annot dep conflicts
136

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

139 140
# Variables added for checking realizations
GENERATED_PREFIX_COQ="lib/coq"
141
GENERATED_PREFIX_ISABELLE=lib/isabelle
142

143 144 145 146 147 148 149
ifeq (@enable_why3_lib@,yes)
WHY3CMA  = lib/why3/why3.cma
WHY3CMXA = lib/why3/why3.cmxa
else
WHY3CMA  =
WHY3CMXA =
endif
150

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
151 152 153
###############
# main target
###############
154

155
ifeq (@enable_why3_lib@,yes)
156
all: @OCAMLBEST@
157 158 159 160
else
all:
endif

161 162 163
plugins: plugins.@OCAMLBEST@
opt: plugins.opt
byte: plugins.byte
Francois Bobot's avatar
Francois Bobot committed
164

165 166 167 168
ifeq (@enable_local@,yes)
all: install_local
endif

169 170 171 172
.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
173
.PHONY: ide install-ide uninstall-ide
174 175
.PHONY: coq install-coq uninstall-coq clean-coq
.PHONY: pvs install-pvs uninstall-pvs clean-pvs
176
.PHONY: install-isabelle
177
.PHONY: plugins plugins.byte plugins.opt
178

179 180 181 182
CLEANDIRS =
CLEANLIBS =
GENERATED =

183 184 185
##############
# Why3 library
##############
186

187
LIBGENERATED = src/util/config.ml \
188 189
	       src/util/rc.ml src/util/lexlib.ml \
	       src/util/json_parser.mli src/util/json_parser.ml \
190
	       src/util/json_lexer.ml src/util/mlmpfr_wrapper.ml \
191
	       src/parser/lexer.ml \
192 193
	       src/parser/parser.mli src/parser/parser.ml \
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
194
	       src/driver/driver_lexer.ml \
195 196
	       src/driver/parse_smtv2_model_parser.mli src/driver/parse_smtv2_model_parser.ml \
	       src/driver/parse_smtv2_model_lexer.ml \
197
	       src/session/compress.ml src/session/xml.ml \
198
	       src/session/strategy_parser.ml
199

200
LIB_UTIL = config bigInt mlmpfr_wrapper util opt lists strings \
201
	   pp extmap extset exthtbl weakhtbl \
202
	   hashcons wstdlib exn_printer \
203
	   json_base json_parser json_lexer \
204
	   debug loc lexlib print_tree \
Mário Pereira's avatar
Mário Pereira committed
205
	   cmdline warning sysutil rc plugin bigInt number vector pqueue
206

207
LIB_CORE = ident ty term pattern decl coercion theory \
208
	   task pretty dterm env trans printer model_parser
209

210
LIB_DRIVER = prove_client call_provers driver_ast driver_parser driver_lexer driver \
211 212 213 214
		whyconf autodetection \
		smt2_model_defs parse_smtv2_model_parser \
		collect_data_model parse_smtv2_model_lexer parse_smtv2_model \
		parse_smtv2_model
215

216
LIB_MLW = ity expr pdecl eval_match typeinv vc pmodule dexpr big_real \
217 218
          pinterp mltree compile mlinterp pdriver cprinter ml_printer \
	  ocaml_printer cakeml_printer
219

220
LIB_PARSER = ptree glob typing parser typing lexer
221

222
LIB_TRANSFORM = simplify_formula inlining split_goal \
223
		args_wrapper detect_polymorphism reduction_engine compute \
224
		eliminate_definition eliminate_algebraic \
225
		abstract_quantifiers eliminate_unknown_types \
226
		eliminate_unknown_lsymbols eliminate_symbol \
227
		eliminate_inductive eliminate_let eliminate_if \
228 229 230 231
		libencoding discriminate encoding encoding_select \
		encoding_guards_full encoding_tags_full \
		encoding_guards encoding_tags encoding_twin \
		encoding_sort simplify_array filter_trigger \
232
		abstraction close_epsilon lift_epsilon \
233
		eliminate_epsilon intro_projections_counterexmp \
Andrei Paskevich's avatar
Andrei Paskevich committed
234
		instantiate_predicate smoke_detector \
235
		prop_curry eliminate_literal \
236
		generic_arg_trans_utils case apply subst \
237
		introduction ind_itp destruct cut congruence \
238
		intro_vc_vars_counterexmp prepare_for_counterexmp \
239
		induction induction_pr matching reflection
240

Sylvain Dailler's avatar
Sylvain Dailler committed
241
LIB_PRINTER = cntexmp_printer alt_ergo why3printer smtv1 smtv2 coq\
242
	      pvs isabelle \
243
	      simplify gappa cvc3 yices mathematica
244

245 246 247
LIB_SESSION = compress xml termcode session_itp \
              strategy strategy_parser controller_itp \
	      server_utils itp_communication \
248
	      itp_server json_util
249

250
LIBMODULES =  $(addprefix src/util/, $(LIB_UTIL)) \
251 252
	      $(addprefix src/core/, $(LIB_CORE)) \
	      $(addprefix src/driver/, $(LIB_DRIVER)) \
253
	      $(addprefix src/mlw/, $(LIB_MLW)) \
254
	      $(addprefix src/parser/, $(LIB_PARSER)) \
255
	      $(addprefix src/transform/, $(LIB_TRANSFORM)) \
François Bobot's avatar
François Bobot committed
256
	      $(addprefix src/printer/, $(LIB_PRINTER)) \
257
	      $(addprefix src/session/, $(LIB_SESSION))
258

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

262
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
263 264
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
265

266
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
267
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
268
$(LIBCMX): OFLAGS += -for-pack Why3
269

270 271
$(LIBDEP): $(LIBGENERATED)

272 273 274 275 276 277 278 279 280 281
# Mlmpfr

ifeq (@found_mlmpfr@,yes)
src/util/mlmpfr_wrapper.ml: config.status src/util/mlmpfr_real.ml
	cp src/util/mlmpfr_real.ml $@
else
src/util/mlmpfr_wrapper.ml: config.status src/util/mlmpfr_dummy.ml
	cp src/util/mlmpfr_dummy.ml $@
endif

282 283 284 285 286 287 288 289 290 291
# 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

292 293
# hide deprecated warnings for strings

294 295
src/util/strings.cmo: WARNINGS:=$(WARNINGS)-3
src/util/strings.cmx: WARNINGS:=$(WARNINGS)-3
296

297 298 299
# compiler plugins

ifeq (@enable_compiler_plugins@,yes)
300
src/util/debug_optim.cmxs: src/util/debug_optim.ml
301
	$(SHOW) 'Linking $@'
302
	$(HIDE)$(OCAMLOPT) -I @COMPILERLIBS@ -shared src/util/debug_optim.ml -o $@
303 304 305 306
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
307 308
endif

309
# build targets
310

311
byte: lib/why3/why3.cma
312
opt:  lib/why3/why3.cmxa lib/why3/why3.cmxs
313

314 315
lib/why3/why3.cma: lib/why3/why3.cmo
lib/why3/why3.cmxa: lib/why3/why3.cmx
316
lib/why3/why3.cmxs: lib/why3/why3.cmx
317

318
lib/why3/why3.cmo: $(LIBCMO)
319 320
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $^
321

322
lib/why3/why3.cmx: $(LIBCMX) lib/why3/why3.cmo
323
	$(SHOW) 'Linking  $@'
324
	$(HIDE)$(OCAMLOPT) $(OFLAGS) $(CMIHACK) -pack -o $@ $(filter %.cmx, $^)
325

326
# clean and depend
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
327

328
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
329
-include $(LIBDEP)
330
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
331

332
depend: $(LIBDEP)
333

334
CLEANDIRS += src $(addprefix src/, $(LIBDIRS))
335
CLEANLIBS += lib/why3/why3
336
GENERATED += $(LIBGENERATED)
337

338 339 340
###############
# installation
###############
341

342
uninstall-data::
MARCHE Claude's avatar
MARCHE Claude committed
343 344
	rm -rf $(DATADIR)/why3

345
install-data::
346 347
	$(MKDIR_P) $(DATADIR)/why3
	$(MKDIR_P) $(DATADIR)/why3/vim
348 349
	$(MKDIR_P) $(DATADIR)/why3/vim/ftdetect
	$(MKDIR_P) $(DATADIR)/why3/vim/syntax
350
	$(MKDIR_P) $(DATADIR)/why3/lang
351 352
	$(MKDIR_P) $(DATADIR)/why3/stdlib
	$(MKDIR_P) $(DATADIR)/why3/stdlib/mach
353
	$(MKDIR_P) $(DATADIR)/why3/drivers
354
	$(INSTALL_DATA) stdlib/*.mlw $(DATADIR)/why3/stdlib
355
	$(INSTALL_DATA) stdlib/mach/*.mlw $(DATADIR)/why3/stdlib/mach
356 357 358 359 360
	$(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
361 362
	$(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
363
	$(INSTALL_DATA) share/lang/why3.lang $(DATADIR)/why3/lang/why3.lang
364

365 366
ifeq (@enable_local@,yes)
else
367 368 369 370
install:: install-bin install-data

uninstall:: uninstall-bin uninstall-data
	rm -rf $(LIBDIR)/why3
371 372
endif

373 374 375 376
uninstall-lib:
	if test -d $(OCAMLINSTALLLIB) -a -w $(OCAMLINSTALLLIB); then \
	  rm -rf $(OCAMLINSTALLLIB)/why3; \
	fi
MARCHE Claude's avatar
MARCHE Claude committed
377

378
uninstall:: uninstall-lib
Kate's avatar
Kate committed
379

380 381 382 383
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
384

385 386 387 388 389 390 391
##################
# Why3 emacs mode
##################

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

392
uninstall-emacs:
Kate's avatar
Kate committed
393 394 395
	rm -f $(DATADIR)/emacs/site-lisp/why3.el
	rm -f $(DATADIR)/emacs/site-lisp/why3.elc

396 397 398
uninstall:: uninstall-emacs

install-emacs:
399
	$(MKDIR_P) $(DATADIR)/emacs/site-lisp/
400
	$(INSTALL_DATA) share/emacs/why3.el $(DATADIR)/emacs/site-lisp/why3.el
401
ifeq (@enable_emacs_compilation@,yes)
402
	$(INSTALL_DATA) share/emacs/why3.elc $(DATADIR)/emacs/site-lisp/why3.elc
Kate's avatar
Kate committed
403 404
endif

405 406
install:: install-emacs

407
ifeq (@enable_emacs_compilation@,yes)
408
all: share/emacs/why3.elc
409 410
endif

Kate's avatar
Kate committed
411

412
##################
413
# Why3 plugins
414 415
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
416
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
417
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
418 419
		plugins/python/py_lexer.ml \
		plugins/python/py_parser.ml plugins/python/py_parser.mli \
420 421
		plugins/microc/mc_lexer.ml \
		plugins/microc/mc_parser.ml plugins/microc/mc_parser.mli \
422
		plugins/parser/dimacs.ml \
423

424
PLUG_PARSER = genequlin dimacs
425
PLUG_PRINTER =
426
PLUG_TRANSFORM =
427
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
428
PLUG_PYTHON = py_ast py_parser py_lexer py_main
429
PLUG_MICROC = mc_ast mc_parser mc_lexer mc_main
430

431
PLUGINS = genequlin dimacs tptp python microc
432

433
TPTPMODULES = $(addprefix plugins/tptp/, $(PLUG_TPTP))
434
PYTHONMODULES = $(addprefix plugins/python/, $(PLUG_PYTHON))
435
MICROCMODULES = $(addprefix plugins/microc/, $(PLUG_MICROC))
Andrei Paskevich's avatar
Andrei Paskevich committed
436

437 438
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
439

440 441 442
PYTHONCMO = $(addsuffix .cmo, $(PYTHONMODULES))
PYTHONCMX = $(addsuffix .cmx, $(PYTHONMODULES))

443 444 445
MICROCCMO = $(addsuffix .cmo, $(MICROCMODULES))
MICROCCMX = $(addsuffix .cmx, $(MICROCMODULES))

446 447 448 449 450 451 452 453 454 455
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

456 457
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
458
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
459
	      $(TPTPMODULES) $(PYTHONMODULES) $(MICROCMODULES)
460

461
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
462 463 464
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

465
PLUGDIRS = parser printer transform tptp python microc
466 467
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

468
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
469 470
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

471 472
$(PLUGDEP): $(PLUGGENERATED)

473 474
LIBPLUGCMO =  $(PLUGINS:%=lib/plugins/%.cmo)
LIBPLUGCMXS = $(PLUGINS:%=lib/plugins/%.cmxs)
475 476 477

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

479 480
lib/plugins:
	mkdir lib/plugins
481

482
lib/plugins/%.cmxs: | lib/plugins
483
	$(SHOW) 'Linking  $@'
484
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -shared -o $@ $^
485

486
lib/plugins/%.cmo: | lib/plugins
487
	$(SHOW) 'Linking  $@'
488
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $^
489

490 491
lib/plugins/%.cmxs: plugins/parser/%.cmx
lib/plugins/%.cmo: plugins/parser/%.cmo
492 493 494 495
lib/plugins/%.cmxs: plugins/printer/%.cmx
lib/plugins/%.cmo: plugins/printer/%.cmo
lib/plugins/%.cmxs: plugins/transform/%.cmx
lib/plugins/%.cmo: plugins/transform/%.cmo
496 497
lib/plugins/tptp.cmxs: $(TPTPCMX)
lib/plugins/tptp.cmo: $(TPTPCMO)
498 499
lib/plugins/python.cmxs: $(PYTHONCMX)
lib/plugins/python.cmo: $(PYTHONCMO)
500 501
lib/plugins/microc.cmxs: $(MICROCCMX)
lib/plugins/microc.cmo: $(MICROCCMO)
502

503 504
# depend and clean targets

505
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
506
-include $(PLUGDEP)
507 508
endif

509
depend: $(PLUGDEP)
510

511 512
CLEANDIRS += plugins $(addprefix plugins/, $(PLUGDIRS)) lib/plugins
GENERATED += $(PLUGGENERATED)
513

514 515 516 517 518
uninstall-bin::
	rm -f $(PLUGINS:%=$(LIBDIR)/why3/plugins/%.cmo)
	rm -f $(PLUGINS:%=$(LIBDIR)/why3/plugins/%.cmxs)

install-bin::
519 520
	$(MKDIR_P) $(LIBDIR)/why3/plugins
	$(INSTALL_DATA) $(wildcard $(LIBPLUGCMO) $(LIBPLUGCMXS)) $(LIBDIR)/why3/plugins
521

522 523 524 525
###############
# Why3 commands
###############

526 527 528 529 530
TOOLSGENERATED = src/tools/why3wc.ml

TOOLS_BIN = why3config why3execute why3extract why3prove \
	    why3realize why3replay why3wc

531
TOOLS_FILES = main $(TOOLS_BIN)
532 533 534 535 536 537 538 539 540 541

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

542 543
$(TOOLSDEP): $(TOOLSGENERATED)

544 545 546
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

547 548 549
bin:
	mkdir bin

550 551 552 553 554 555 556 557 558 559 560 561 562 563
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
564 565 566
bin/why3wc.opt: src/tools/why3wc.cmx
bin/why3wc.byte: src/tools/why3wc.cmo

567 568 569
uninstall-bin::
	rm -f $(BINDIR)/why3$(EXE)
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE))
Kate's avatar
Kate committed
570

571 572
install-bin::
	$(MKDIR_P) $(BINDIR)
573
	$(INSTALL) bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
574
	$(MKDIR_P) $(TOOLDIR)
575 576 577 578 579 580 581
	$(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)
582 583

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

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

588
install_local:: share/drivers share/stdlib
589 590 591 592

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

593 594
share/stdlib:
	ln -snf ../stdlib share/stdlib
595

596
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
597
-include $(TOOLSDEP)
598 599
endif

600
depend: $(TOOLSDEP)
601

602 603 604
CLEANDIRS += src/tools
GENERATED += $(TOOLSGENERATED)

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
605
clean::
606
	rm -f bin/why3*
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
607

608 609 610
##############
# test targets
##############
611

612 613
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
614

615 616
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
617

618 619
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
620

621 622
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
623

624
%.type: %.mlw bin/why3ide.opt
625
	bin/why3.opt --type-only $*.mlw
626

627 628 629 630
##############
# Why3server #
##############

631
SERVER_MODULES := logging arraylist options queue readbuf request \
632
		  proc writebuf server-unix server-win
633 634 635

CPULIM_MODULES := cpulimit-unix cpulimit-win

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

638
CPULIM_O := $(CPULIM_MODULES:%=src/server/%.o)
639

640 641
TOOLS = lib/why3server$(EXE) lib/why3cpulimit$(EXE)

642
all: $(TOOLS)
643

644
lib/why3server$(EXE): $(SERVER_O)
645 646 647 648
	$(CC) -Wall -o $@ $^

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

650
%.o: %.c
651
	$(CC) -Wall -O -g -o $@ -c $<
652

653 654 655 656 657
uninstall-bin::
	rm -f $(LIBDIR)/why3/why3server$(EXE) $(LIBDIR)/why3/why3cpulimit$(EXE)
	rm -f $(LIBDIR)/why3/why3-call-pvs

install-bin::
658 659 660 661
	$(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
662 663

clean::
664
	rm -f $(SERVER_O) $(CPULIM_O) $(TOOLS)
665

666 667 668 669
##########
# gallery
##########

670
# we export exactly the programs that have a why3session.xml file
671 672 673

.PHONY: gallery

674 675 676 677 678
gallery:: gallery-simple gallery-subs

.PHONY: gallery-simple

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

693 694
.PHONY: gallery-subs

695
GALLERYSUBS=WP_revisited verifythis_2016_matrix_multiplication avl double_wp prover multiprecision
696 697

gallery-subs::
698
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
699 700
	@for d in $(GALLERYSUBS) ; do \
	  echo "exporting examples/$$d"; \
701
	  mkdir -p $(GALLERYDIR)/$$d; \
702
	  cd examples/$$d; \
703
	  WHY3CONFIG="" ../../bin/why3doc.@OCAMLBEST@ -L ../../stdlib -L . --stdlib-url http://why3.lri.fr/stdlib/ --debug ignore_unused_vars *.mlw -o $(GALLERYDIR)/$$d; \
704
	  cd ..; \
705
	  rm -f $(GALLERYDIR)/$$d/$$d.zip; \
706
	  git archive --format=zip -o $(GALLERYDIR)/$$d/$$d.zip HEAD $$d; \
707 708 709 710
	  cd ..; \
	done


711 712 713 714 715 716
%-gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
	x=$*/why3session.xml; \
	d=`dirname $$x`; \
	f=`basename $$d`; \
	echo "exporting $$f"; \
717
	rm -f $$d/*.bak; \
718
	mkdir -p $(GALLERYDIR)/$$f; \
719
	WHY3CONFIG="" bin/why3session.@OCAMLBEST@ html $$d -o $(GALLERYDIR)/$$f; \
720 721
	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; \
722
	cd examples/; \
723 724
	rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	zip -q -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f
725

MARCHE Claude's avatar
MARCHE Claude committed
726 727 728 729 730 731 732 733
########
# XML DTD validation
########

.PHONY: xml-validate

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

737 738 739 740 741
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
742 743 744 745
###############
# IDE
###############

746 747
ifeq (@enable_ide@,yes)

748 749 750
IDEGENERATED = src/ide/gtkcompat.ml

IDE_FILES = gtkcompat gconfig ide_utils why3ide
MARCHE Claude's avatar
MARCHE Claude committed
751 752 753

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

754
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
755 756 757
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

758
$(IDEDEP): DEPFLAGS += -I src/ide
759
$(IDECMO) $(IDECMX): INCLUDES += -I src/ide
MARCHE Claude's avatar
MARCHE Claude committed
760

761 762
$(IDEDEP): $(IDEGENERATED)

763
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
764

765 766
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
767

768 769
bin/why3ide.opt bin/why3ide.byte: INCLUDES += @LABLGTKINCLUDE@
bin/why3ide.opt bin/why3ide.byte: EXTLIBS += @LABLGTKLIB@
770
bin/why3ide.byte: BLINKFLAGS += -custom
MARCHE Claude's avatar
MARCHE Claude committed
771

772 773
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
774

775
src/ide/resetgc.o: src/ide/resetgc.c
776 777
	$(SHOW) 'Ocamlc   $<'
	$(HIDE)$(OCAMLC) -c -ccopt "-Wall -o $@" $<
778

MARCHE Claude's avatar
MARCHE Claude committed
779 780
# depend and clean targets

781
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
782
-include $(IDEDEP)
783
endif
MARCHE Claude's avatar
MARCHE Claude committed
784

785
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
786

787
CLEANDIRS += src/ide
MARCHE Claude's avatar
MARCHE Claude committed
788

789 790 791
ide: bin/why3ide.@OCAMLBEST@

uninstall-ide:
792
	rm -f $(TOOLDIR)/why3ide$(EXE)
793
	rm -rf $(DATADIR)/why3/images
Kate's avatar
Kate committed
794

795
uninstall:: uninstall-ide
Kate's avatar
Kate committed
796

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

811
install_local:: bin/why3ide
812

813 814 815 816 817 818
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 $@
819
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
820

821 822 823
GENERATED += $(IDEGENERATED)

endif
824

825 826 827 828
###############
# WEBSERV
###############

829
WEBSERV_FILES = wserver why3web
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844

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

845
bin/why3webserver.opt: $(WHY3CMXA) $(WEBSERVCMX)
846 847 848
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

849
bin/why3webserver.byte: $(WHY3CMA) $(WEBSERVCMO)
850 851 852 853 854 855 856 857 858 859 860 861 862
	$(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

863 864
uninstall-bin::
	rm -f $(TOOLDIR)/why3webserver$(EXE)
865

866 867
install-bin::
	$(MKDIR_P) $(TOOLDIR)
868 869 870 871 872
	$(INSTALL) bin/why3webserver.@OCAMLBEST@ $(TOOLDIR)/why3webserver$(EXE)

install_local:: bin/why3webserver


873 874 875 876
###############
# Session
###############

877
SESSION_FILES = why3session_lib why3session_info \
878
		why3session_html why3session_latex why3session_update \
879
		why3session_main
880
# TODO: why3session_copy why3session_rm why3session_csv why3session_run
881
#       why3session_output
882 883 884

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

885
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
886 887 888
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

889
$(SESSIONDEP): DEPFLAGS += -I src/why3session
890 891 892 893 894 895 896
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

897 898
bin/why3session.opt: $(WHY3CMXA) $(SESSIONCMX)
bin/why3session.byte: $(WHY3CMA) $(SESSIONCMO)
899 900 901

# depend and clean targets

902
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
903
-include $(SESSIONDEP)
904
endif
905

906
depend: $(SESSIONDEP)
907

908
CLEANDIRS += src/why3session
909

910 911
uninstall-bin::
	rm -f $(TOOLDIR)/why3session$(EXE)
Kate's avatar
Kate committed
912

913 914
install-bin::
	$(MKDIR_P) $(TOOLDIR)
915
	$(INSTALL) bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
916

917
install_local:: bin/why3session
918

MARCHE Claude's avatar
MARCHE Claude committed
919 920 921 922
###############
# Why3 Shell
###############

923
SHELL_FILES = unix_scheduler why3shell
MARCHE Claude's avatar
MARCHE Claude committed
924

925
SHELLMODULES = $(addprefix src/tools/, $(SHELL_FILES))
MARCHE Claude's avatar
MARCHE Claude committed
926 927 928 929 930

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

931 932
$(SHELLDEP): DEPFLAGS += -I src/tools
$(SHELLCMO) $(SHELLCMX): INCLUDES += -I src/tools
MARCHE Claude's avatar
MARCHE Claude committed
933 934 935 936 937 938

# build targets

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

939
bin/why3shell.opt: $(WHY3CMXA) $(SHELLCMX)
MARCHE Claude's avatar
MARCHE Claude committed
940 941 942
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

943
bin/why3shell.byte: $(WHY3CMA) $(SHELLCMO)
MARCHE Claude's avatar
MARCHE Claude committed
944 945 946 947 948 949 950 951 952 953 954
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

# depend and clean targets

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

depend: $(SHELLDEP)

955 956
uninstall-bin::
	rm -f $(TOOLDIR)/why3shell$(EXE)
MARCHE Claude's avatar
MARCHE Claude committed
957

958 959
install-bin::
	$(MKDIR_P) $(TOOLDIR)
MARCHE Claude's avatar
MARCHE Claude committed
960 961 962 963
	$(INSTALL) bin/why3shell.@OCAMLBEST@ $(TOOLDIR)/why3shell$(EXE)

install_local:: bin/why3shell

964 965 966 967
####################
# Coq realizations
####################

968
COQVERSIONSPECIFIC=
969 970 971 972 973 974 975 976 977 978 979 980 981

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)


982
COQLIBS_INT_FILES = Abs ComputerDivision Div2 EuclideanDivision Int MinMax Power NumOf
983 984
COQLIBS_INT_ALL_FILES = Exponentiation $(COQLIBS_INT_FILES)
COQLIBS_INT = $(addprefix lib/coq/int/, $(COQLIBS_INT_ALL_FILES))
985

986 987 988
COQLIBS_BOOL_FILES = Bool
COQLIBS_BOOL = $(addprefix lib/coq/bool/, $(COQLIBS_BOOL_FILES))

989
ifeq (@enable_coq_fp_libs@,yes)
990
COQLIBS_REAL_FILES = Abs ExpLog FromInt MinMax PowerInt PowerReal Real RealInfix Square Trigonometry Truncate
991 992 993
else
COQLIBS_REAL_FILES = Abs ExpLog FromInt MinMax PowerInt PowerReal Real RealInfix Square Trigonometry
endif
994 995
COQLIBS_REAL = $(addprefix lib/coq/real/, $(COQLIBS_REAL_FILES))

996
COQLIBS_NUMBER_FILES = Divisibility Gcd Parity Prime Coprime
997 998
COQLIBS_NUMBER = $(addprefix lib/coq/number/, $(COQLIBS_NUMBER_FILES))

999
COQLIBS_SET_FILES = Set Cardinal Fset FsetInduction FsetInt FsetSum SetApp SetAppInt SetImp SetImpInt
1000 1001
COQLIBS_SET = $(addprefix lib/coq/set/, $(COQLIBS_SET_FILES))

MARCHE Claude's avatar
MARCHE Claude committed
1002
COQLIBS_MAP_FILES = Map Const Occ MapPermut MapInjection
1003 1004
COQLIBS_MAP = $(addprefix lib/coq/map/, $(COQLIBS_MAP_FILES))

1005
COQLIBS_LIST_FILES = List Length Mem Nth NthLength HdTl NthHdTl Append NthLengthAppend Reverse HdTlNoOpt NthNoOpt RevAppend Combine Distinct NumOcc Permut
1006 1007 1008 1009 1010
COQLIBS_LIST = $(addprefix lib/coq/list/, $(COQLIBS_LIST_FILES))

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

1011 1012 1013
COQLIBS_BV_FILES = Pow2int BV_Gen
COQLIBS_BV = $(addprefix lib/coq/bv/, $(COQLIBS_BV_FILES))

1014
ifeq (@enable_coq_fp_libs@,yes)
1015
COQLIBS_FP_FILES = Rounding SingleFormat Single DoubleFormat Double
1016 1017
COQLIBS_FP_ALL_FILES = GenFloat $(COQLIBS_FP_FILES)
COQLIBS_FP = $(addprefix lib/coq/floating_point/, $(COQLIBS_FP_ALL_FILES))
1018

1019
COQLIBS_IEEEFLOAT_FILES = RoundingMode GenericFloat Float32 Float64
1020
COQLIBS_IEEEFLOAT = $(addprefix lib/coq/ieee_float/, $(COQLIBS_IEEEFLOAT_FILES))
1021
endif
1022

1023
COQLIBS_FOR_DRIVERS_FILES = ComputerOfEuclideanDivision
1024
COQLIBS_FOR_DRIVERS = $(addprefix lib/coq/for_drivers/, $(COQLIBS_FOR_DRIVERS_FILES))
1025

1026
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)
1027

1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039
%.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))

1040
coq: $(COQVO) drivers/coq-realizations.aux lib/coq/version
1041 1042

clean-coq:
1043
	rm -f $(COQVO) $(COQVD) $(addsuffix .glob, $(COQLIBS_FILES)) lib/coq/version
1044 1045

clean:: clean-coq
1046

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

1078
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
1079

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

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

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

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

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

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

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

1101
update-coq-option: bin/why3realize.@OCAMLBEST@ drivers/coq-realizations.aux stdlib/option.mlw
1102
	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
1103