Makefile.in 73.1 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.                           #
#                                                                  #
####################################################################
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
11

12 13 14
VERBOSEMAKE ?= @enable_verbose_make@

ifeq ($(VERBOSEMAKE),yes)
15 16
  SHOW = @true
  HIDE =
17
else
18 19
  SHOW = @echo
  HIDE = @
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
20 21
endif

22
# install the binaries
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
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
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
34

Andrei Paskevich's avatar
Andrei Paskevich committed
35
# OS specific stuff
36
EXE   = @EXE@
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
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@
55 56
COQCAMLP  = @COQCAMLP@
COQCAMLPLIB = @COQCAMLPLIB@
MARCHE Claude's avatar
MARCHE Claude committed
57
FRAMAC_LIBDIR = $(DESTDIR)@FRAMAC_LIBDIR@
58

59 60 61 62 63 64
ifeq (@enable_menhirLib@,yes)
MENHIR	  = @MENHIR@ --table
else
MENHIR	  = @MENHIR@
endif

65 66 67 68 69
DEPFLAGS = -slash

ifeq (@enable_why3_lib@,yes)
DEPFLAGS += -I lib/why3
endif
70
ifeq (@OCAMLBEST@,opt)
71 72
# the semantics of the -native flag changed in ocaml 4.03.0
#DEPFLAGS += -native
73 74
endif

75
RUBBER = @RUBBER@
76
HEVEA = @HEVEA@
77
HACHA = @HACHA@
78
EMACS = @EMACS@
79

80
#PSVIEWER  = @PSVIEWER@
Andrei Paskevich's avatar
Andrei Paskevich committed
81
#PDFVIEWER = @PDFVIEWER@
82

83
INCLUDES = @WHY3INCLUDE@ @ZIPINCLUDE@ @MENHIRINCLUDE@
84 85 86 87 88 89 90 91 92 93

# 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.
94
#   50   Unexpected documentation comment.
95 96 97
#   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.
98 99 100 101 102
# - fatal:
#   5    Partially applied function: expression whose result has function
#        type and is ignored.
#   48   Implicit elimination of optional arguments.

103
WARNINGS = A-4-9-41-44-45-50-52@5@48
104

105 106
OFLAGS = -w $(WARNINGS) -safe-string -keep-locs -bin-annot -dtypes -g $(INCLUDES)
BFLAGS = -w $(WARNINGS) -safe-string -keep-locs -bin-annot -dtypes -g $(INCLUDES)
107 108 109

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

111
ifeq (@enable_profiling@,yes)
112 113 114
OFLAGS += -g -p
endif

115 116 117
# see http://caml.inria.fr/mantis/view.php?id=4991
CMIHACK = -intf-suffix .cmi

118 119
# external libraries common to all binaries

120
EXTOBJS = @MENHIRLIB@
121
EXTLIBS = str unix nums dynlink @ZIPLIB@ @WHY3LIB@
122

123 124
EXTCMA	= $(addsuffix .cmo,$(EXTOBJS)) $(addsuffix .cma,$(EXTLIBS))
EXTCMXA = $(addsuffix .cmx,$(EXTOBJS)) $(addsuffix .cmxa,$(EXTLIBS))
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
125

126
INSTALLED_LIB_EXTS = a cma cmx cmi cmxa cmxs
127
COMPILED_LIB_EXTS = $(INSTALLED_LIB_EXTS) o cmo cmt cmti annot dep conflicts
128

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

131 132
# Variables added for checking realizations
GENERATED_PREFIX_COQ="lib/coq"
133
GENERATED_PREFIX_ISABELLE=lib/isabelle
134

135 136 137 138 139 140 141 142
ifeq (@enable_why3_lib@,yes)
WHY3CMA  = lib/why3/why3.cma
WHY3CMXA = lib/why3/why3.cmxa
else
WHY3CMA  =
WHY3CMXA =
endif

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
143 144 145
###############
# main target
###############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
146

147
ifeq (@enable_why3_lib@,yes)
148
all: @OCAMLBEST@
149 150 151 152
else
all:
endif

153 154 155
plugins: plugins.@OCAMLBEST@
opt: plugins.opt
byte: plugins.byte
Francois Bobot's avatar
Francois Bobot committed
156

157 158 159 160
ifeq (@enable_local@,yes)
all: install_local
endif

161 162 163 164
.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
165
.PHONY: ide install-ide uninstall-ide
166 167 168
.PHONY: coq install-coq-tactic install-coq install-coq-data
.PHONY: pvs install-pvs install-pvs-data
.PHONY: install-isabelle
169
.PHONY: plugins plugins.byte plugins.opt
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
170

171 172 173 174
CLEANDIRS =
CLEANLIBS =
GENERATED =

175 176 177
##############
# Why3 library
##############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
178

179
LIBGENERATED = src/util/config.ml \
180 181 182 183
	       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 \
184 185
	       src/parser/parser.mli src/parser/parser.ml \
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
186
	       src/driver/driver_lexer.ml \
187 188
	       src/driver/parse_smtv2_model_parser.mli src/driver/parse_smtv2_model_parser.ml \
	       src/driver/parse_smtv2_model_lexer.ml \
189
	       src/session/compress.ml src/session/xml.ml \
190
	       src/session/strategy_parser.ml \
191
	       lib/ocaml/why3__BigInt_compat.ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
192

193
LIB_UTIL = config bigInt util opt lists strings \
194
	   pp extmap extset exthtbl weakhtbl \
195
	   hashcons stdlib exn_printer \
196
	   json_base json_parser json_lexer \
197
	   debug loc lexlib print_tree \
198
	   cmdline warning sysutil rc plugin bigInt number pqueue
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
199

200
LIB_CORE = ident ty term pattern decl coercion theory \
201
	   task pretty_sig pretty dterm env trans printer model_parser
202

203
LIB_DRIVER = prove_client call_provers driver_ast driver_parser driver_lexer driver \
204 205 206 207
		whyconf autodetection \
		smt2_model_defs parse_smtv2_model_parser \
		collect_data_model parse_smtv2_model_lexer parse_smtv2_model \
		parse_smtv2_model
208

209
LIB_MLW = ity expr pdecl eval_match typeinv vc pmodule dexpr \
210
          pinterp mltree compile pdriver cprinter ocaml_printer
211

212
LIB_PARSER = ptree glob typing parser lexer
213

214
LIB_TRANSFORM = simplify_formula inlining split_goal \
215
		args_wrapper detect_polymorphism reduction_engine compute \
216
		eliminate_definition eliminate_algebraic \
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 \
Guillaume Melquiond's avatar
Guillaume Melquiond committed
226
		prop_curry eliminate_literal \
227
		generic_arg_trans_utils case apply \
228
		ind_itp destruct cut \
229
		induction induction_pr matching reification
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

Andrei Paskevich's avatar
Andrei Paskevich committed
252
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
253 254
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
255

Andrei Paskevich's avatar
Andrei Paskevich committed
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
# hide deprecated warnings for strings

284 285
src/util/strings.cmo: WARNINGS:=$(WARNINGS)-3
src/util/strings.cmx: WARNINGS:=$(WARNINGS)-3
286

287 288 289
# compiler plugins

ifeq (@enable_compiler_plugins@,yes)
290
src/util/debug_optim.cmxs: src/util/debug_optim.ml
Raphael Rieu-Helft's avatar
Raphael Rieu-Helft committed
291
	$(SHOW) 'Linking $@'
292 293
	$(HIDE)$(OCAMLOPT) -I @COMPILERLIBS@ -shared src/util/debug_optim.ml -o $@
src/transform/reification.cmx: src/util/debug_optim.cmxs
294 295 296
src/transform/reification.cmx: OFLAGS += -plugin debug_optim.cmxs
endif

297 298
# hide warning 'no cmx file was found in path for module ..., and its interface was not compiled with -opaque' for the coq tactic

299
src/coq-tactic/why3tac.cmx: WARNINGS:=$(WARNINGS)-58
300

301
# build targets
302

303
byte: lib/why3/why3.cma
304
opt:  lib/why3/why3.cmxa lib/why3/why3.cmxs
305

306 307
lib/why3/why3.cma: lib/why3/why3.cmo
lib/why3/why3.cmxa: lib/why3/why3.cmx
308
lib/why3/why3.cmxs: lib/why3/why3.cmx
309

310
lib/why3/why3.cmo: $(LIBCMO)
311 312
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $^
313

314
lib/why3/why3.cmx: $(LIBCMX) lib/why3/why3.cmo
315
	$(SHOW) 'Linking  $@'
316
	$(HIDE)$(OCAMLOPT) $(OFLAGS) $(CMIHACK) -pack -o $@ $(filter %.cmx, $^)
317

Andrei Paskevich's avatar
Andrei Paskevich committed
318
# clean and depend
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
319

320
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
321
-include $(LIBDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
322
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
323

324
depend: $(LIBDEP)
325

326
CLEANDIRS += src $(addprefix src/, $(LIBDIRS))
327
CLEANLIBS += lib/why3/why3
328
GENERATED += $(LIBGENERATED)
329

330 331 332
###############
# installation
###############
333

334
uninstall-data::
MARCHE Claude's avatar
MARCHE Claude committed
335 336
	rm -rf $(DATADIR)/why3

337
install-data::
338 339
	$(MKDIR_P) $(DATADIR)/why3
	$(MKDIR_P) $(DATADIR)/why3/vim
340 341
	$(MKDIR_P) $(DATADIR)/why3/vim/ftdetect
	$(MKDIR_P) $(DATADIR)/why3/vim/syntax
342
	$(MKDIR_P) $(DATADIR)/why3/lang
343 344
	$(MKDIR_P) $(DATADIR)/why3/stdlib
	$(MKDIR_P) $(DATADIR)/why3/stdlib/mach
345
	$(MKDIR_P) $(DATADIR)/why3/drivers
346
	$(INSTALL_DATA) stdlib/*.mlw $(DATADIR)/why3/stdlib
347
	$(INSTALL_DATA) stdlib/mach/*.mlw $(DATADIR)/why3/stdlib/mach
348 349 350 351 352
	$(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
353 354
	$(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
355
	$(INSTALL_DATA) share/lang/why3.lang $(DATADIR)/why3/lang/why3.lang
356

357 358
ifeq (@enable_local@,yes)
else
359 360 361 362
install:: install-bin install-data

uninstall:: uninstall-bin uninstall-data
	rm -rf $(LIBDIR)/why3
363 364
endif

365 366 367 368
uninstall-lib:
	if test -d $(OCAMLINSTALLLIB) -a -w $(OCAMLINSTALLLIB); then \
	  rm -rf $(OCAMLINSTALLLIB)/why3; \
	fi
MARCHE Claude's avatar
MARCHE Claude committed
369

370
uninstall:: uninstall-lib
Kate's avatar
Kate committed
371

372 373 374 375
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
376

377 378 379 380 381 382 383
##################
# Why3 emacs mode
##################

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

384
uninstall-emacs:
Kate's avatar
Kate committed
385 386 387
	rm -f $(DATADIR)/emacs/site-lisp/why3.el
	rm -f $(DATADIR)/emacs/site-lisp/why3.elc

388 389 390
uninstall:: uninstall-emacs

install-emacs:
391
	$(MKDIR_P) $(DATADIR)/emacs/site-lisp/
392
	$(INSTALL_DATA) share/emacs/why3.el $(DATADIR)/emacs/site-lisp/why3.el
393
ifeq (@enable_emacs_compilation@,yes)
394
	$(INSTALL_DATA) share/emacs/why3.elc $(DATADIR)/emacs/site-lisp/why3.elc
Kate's avatar
Kate committed
395 396
endif

397 398
install:: install-emacs

399
ifeq (@enable_emacs_compilation@,yes)
400
all: share/emacs/why3.elc
401 402
endif

Kate's avatar
Kate committed
403

404
##################
405
# Why3 plugins
406 407
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
408
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
409
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
410 411
		plugins/python/py_lexer.ml \
		plugins/python/py_parser.ml plugins/python/py_parser.mli \
412
		plugins/parser/dimacs.ml \
413

414
PLUG_PARSER = genequlin dimacs
415
PLUG_PRINTER =
416
PLUG_TRANSFORM =
417
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
418
PLUG_PYTHON = py_ast py_parser py_lexer py_main
419

420
PLUGINS = genequlin dimacs tptp python
421

422
TPTPMODULES = $(addprefix plugins/tptp/, $(PLUG_TPTP))
423
PYTHONMODULES = $(addprefix plugins/python/, $(PLUG_PYTHON))
Andrei Paskevich's avatar
Andrei Paskevich committed
424

425 426
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
427

428 429 430
PYTHONCMO = $(addsuffix .cmo, $(PYTHONMODULES))
PYTHONCMX = $(addsuffix .cmx, $(PYTHONMODULES))

431 432 433 434 435 436 437 438 439 440
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

441 442
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
443
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
444
	      $(TPTPMODULES) $(PYTHONMODULES)
445

Andrei Paskevich's avatar
Andrei Paskevich committed
446
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
447 448 449
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

450
PLUGDIRS = parser printer transform tptp python
451 452
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
453
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
454 455
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

456 457
$(PLUGDEP): $(PLUGGENERATED)

458 459
LIBPLUGCMO =  $(PLUGINS:%=lib/plugins/%.cmo)
LIBPLUGCMXS = $(PLUGINS:%=lib/plugins/%.cmxs)
460 461 462

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

464 465
lib/plugins:
	mkdir lib/plugins
466

467
lib/plugins/%.cmxs: | lib/plugins
468
	$(SHOW) 'Linking  $@'
469
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -shared -o $@ $^
470

471
lib/plugins/%.cmo: | lib/plugins
472
	$(SHOW) 'Linking  $@'
473
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $^
474

475 476
lib/plugins/%.cmxs: plugins/parser/%.cmx
lib/plugins/%.cmo: plugins/parser/%.cmo
477 478 479 480
lib/plugins/%.cmxs: plugins/printer/%.cmx
lib/plugins/%.cmo: plugins/printer/%.cmo
lib/plugins/%.cmxs: plugins/transform/%.cmx
lib/plugins/%.cmo: plugins/transform/%.cmo
481 482
lib/plugins/tptp.cmxs: $(TPTPCMX)
lib/plugins/tptp.cmo: $(TPTPCMO)
483 484
lib/plugins/python.cmxs: $(PYTHONCMX)
lib/plugins/python.cmo: $(PYTHONCMO)
485

Andrei Paskevich's avatar
Andrei Paskevich committed
486 487
# depend and clean targets

488
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
489
-include $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
490 491
endif

492
depend: $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
493

494 495
CLEANDIRS += plugins $(addprefix plugins/, $(PLUGDIRS)) lib/plugins
GENERATED += $(PLUGGENERATED)
496

497 498 499 500 501
uninstall-bin::
	rm -f $(PLUGINS:%=$(LIBDIR)/why3/plugins/%.cmo)
	rm -f $(PLUGINS:%=$(LIBDIR)/why3/plugins/%.cmxs)

install-bin::
502 503
	$(MKDIR_P) $(LIBDIR)/why3/plugins
	$(INSTALL_DATA) $(wildcard $(LIBPLUGCMO) $(LIBPLUGCMXS)) $(LIBDIR)/why3/plugins
504

505 506 507 508
###############
# Why3 commands
###############

509 510
TOOLSGENERATED = src/tools/why3wc.ml

511
TOOLS_BIN = why3config why3execute why3extract why3prove \
512 513
	    why3realize why3replay why3wc

Andrei Paskevich's avatar
Andrei Paskevich committed
514
TOOLS_FILES = main $(TOOLS_BIN)
515 516 517 518 519 520 521 522 523 524

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

525 526
$(TOOLSDEP): $(TOOLSGENERATED)

527 528 529
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

530 531 532
bin:
	mkdir bin

533 534 535 536 537 538 539 540 541 542 543 544 545 546
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
547 548 549
bin/why3wc.opt: src/tools/why3wc.cmx
bin/why3wc.byte: src/tools/why3wc.cmo

550 551 552
uninstall-bin::
	rm -f $(BINDIR)/why3$(EXE)
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE))
Kate's avatar
Kate committed
553

554 555
install-bin::
	$(MKDIR_P) $(BINDIR)
556
	$(INSTALL) bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
557
	$(MKDIR_P) $(TOOLDIR)
558 559 560 561 562 563 564
	$(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)
565 566

install_local:: bin/why3 $(addprefix bin/,$(TOOLS_BIN))
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
567

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

571
install_local:: share/drivers share/stdlib
572 573 574 575

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

576 577
share/stdlib:
	ln -snf ../stdlib share/stdlib
578

579
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
580
-include $(TOOLSDEP)
581 582
endif

583
depend: $(TOOLSDEP)
584

585 586 587
CLEANDIRS += src/tools
GENERATED += $(TOOLSGENERATED)

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
588
clean::
589
	rm -f bin/why3*
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
590

591 592 593
##############
# test targets
##############
594

595 596
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
597

598 599
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
600

601 602
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
603

604 605
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
606

607
%.type: %.mlw bin/why3ide.opt
608
	bin/why3.opt --type-only $*.mlw
609

610 611 612 613
##############
# Why3server #
##############

614 615 616 617 618
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
619
SERVER_O := $(SERVER_MODULES:%=src/server/%.o)
620

621
CPULIM_O := $(CPULIM_MODULES:%=src/server/%.o)
622

623 624
TOOLS = lib/why3server$(EXE) lib/why3cpulimit$(EXE)

625
all: $(TOOLS)
626

627
lib/why3server$(EXE): $(SERVER_O)
628 629 630 631
	$(CC) -Wall -o $@ $^

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

633
%.o: %.c
634
	$(CC) -Wall -O -g -o $@ -c $<
635

636 637 638 639 640
uninstall-bin::
	rm -f $(LIBDIR)/why3/why3server$(EXE) $(LIBDIR)/why3/why3cpulimit$(EXE)
	rm -f $(LIBDIR)/why3/why3-call-pvs

install-bin::
641 642 643 644
	$(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
645 646

clean::
647
	rm -f $(SERVER_O) $(CPULIM_O) $(TOOLS)
648

649 650 651 652
##########
# gallery
##########

653
# we export exactly the programs that have a why3session.xml file
654 655 656

.PHONY: gallery

657 658 659 660 661
gallery:: gallery-simple gallery-subs

.PHONY: gallery-simple

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

676 677
.PHONY: gallery-subs

678
GALLERYSUBS=WP_revisited verifythis_2016_matrix_multiplication avl double_wp prover
679 680

gallery-subs::
681
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
682 683
	@for d in $(GALLERYSUBS) ; do \
	  echo "exporting examples/$$d"; \
684
	  mkdir -p $(GALLERYDIR)/$$d; \
685
	  cd examples/$$d; \
686
	  WHY3CONFIG="" ../../bin/why3doc.@OCAMLBEST@ -L ../../stdlib -L . --stdlib-url http://why3.lri.fr/stdlib/ *.mlw -o $(GALLERYDIR)/$$d; \
687
	  cd ..; \
688
	  rm -f $(GALLERYDIR)/$$d/$$d.zip; \
689
	  zip -q -r $(GALLERYDIR)/$$d/$$d.zip $$d; \
690 691 692 693
	  cd ..; \
	done


694 695 696 697 698 699
%-gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
	x=$*/why3session.xml; \
	d=`dirname $$x`; \
	f=`basename $$d`; \
	echo "exporting $$f"; \
700
	rm -f $$d/*.bak; \
701
	mkdir -p $(GALLERYDIR)/$$f; \
702
	WHY3CONFIG="" bin/why3session.@OCAMLBEST@ html $$d -o $(GALLERYDIR)/$$f; \
703 704
	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; \
705
	cd examples/; \
706
	rm -f $(GALLERYDIR)/$$f/$$f.zip; \
707
	zip -q -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f
708

MARCHE Claude's avatar
MARCHE Claude committed
709 710 711 712 713 714 715 716
########
# XML DTD validation
########

.PHONY: xml-validate

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

720 721 722 723 724
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
725 726 727 728
###############
# IDE
###############

729 730
ifeq (@enable_ide@,yes)

Sylvain Dailler's avatar
Sylvain Dailler committed
731
IDE_FILES = gconfig ide_utils why3ide
MARCHE Claude's avatar
MARCHE Claude committed
732 733 734

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

Andrei Paskevich's avatar
Andrei Paskevich committed
735
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
736 737 738
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
739
$(IDEDEP): DEPFLAGS += -I src/ide
740
$(IDECMO) $(IDECMX): INCLUDES += -I src/ide
MARCHE Claude's avatar
MARCHE Claude committed
741

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

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

747
bin/why3ide.opt bin/why3ide.byte: INCLUDES += -I @LABLGTK2LIB@
748
bin/why3ide.opt bin/why3ide.byte: EXTLIBS += lablgtk lablgtksourceview2
749
bin/why3ide.byte: BLINKFLAGS += -custom
MARCHE Claude's avatar
MARCHE Claude committed
750

751 752
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
753

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

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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
764
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
765

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

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

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

774 775 776
uninstall:: uninstall-ide

install-ide:
777
	$(MKDIR_P) $(TOOLDIR)
778
	$(INSTALL) bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
779 780 781 782 783 784 785 786 787 788
	$(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
789

790
install_local:: bin/why3ide
791

792
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
793

794

795 796 797 798
###############
# WEBSERV
###############

799
WEBSERV_FILES = wserver why3web
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814

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

815
bin/why3webserver.opt: $(WHY3CMXA) $(WEBSERVCMX)
816 817 818
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

819
bin/why3webserver.byte: $(WHY3CMA) $(WEBSERVCMO)
820 821 822 823 824 825 826 827 828 829 830 831 832
	$(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

833 834
uninstall-bin::
	rm -f $(TOOLDIR)/why3webserver$(EXE)
835

836 837
install-bin::
	$(MKDIR_P) $(TOOLDIR)
838 839 840 841 842
	$(INSTALL) bin/why3webserver.@OCAMLBEST@ $(TOOLDIR)/why3webserver$(EXE)

install_local:: bin/why3webserver


843 844 845 846
###############
# Session
###############

847
SESSION_FILES = why3session_lib why3session_info \
848
		why3session_html why3session_latex \
849
		why3session_main
850
# TODO: why3session_copy why3session_rm why3session_csv why3session_run
851
#       why3session_output
852 853 854

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

Andrei Paskevich's avatar
Andrei Paskevich committed
855
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
856 857 858
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
859
$(SESSIONDEP): DEPFLAGS += -I src/why3session
860 861 862 863 864 865 866
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

867 868
bin/why3session.opt: $(WHY3CMXA) $(SESSIONCMX)
bin/why3session.byte: $(WHY3CMA) $(SESSIONCMO)
869 870 871

# depend and clean targets

872
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
873
-include $(SESSIONDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
874
endif
875

Andrei Paskevich's avatar
Andrei Paskevich committed
876
depend: $(SESSIONDEP)
877

878
CLEANDIRS += src/why3session
879

880 881
uninstall-bin::
	rm -f $(TOOLDIR)/why3session$(EXE)
Kate's avatar
Kate committed
882

883 884
install-bin::
	$(MKDIR_P) $(TOOLDIR)
885
	$(INSTALL) bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
886

887
install_local:: bin/why3session
888

MARCHE Claude's avatar
MARCHE Claude committed
889 890 891 892
###############
# Why3 Shell
###############

Sylvain Dailler's avatar
Sylvain Dailler committed
893
SHELL_FILES = unix_scheduler why3shell
MARCHE Claude's avatar
MARCHE Claude committed
894

895
SHELLMODULES = $(addprefix src/tools/, $(SHELL_FILES))
MARCHE Claude's avatar
MARCHE Claude committed
896 897 898 899 900

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

901 902
$(SHELLDEP): DEPFLAGS += -I src/tools
$(SHELLCMO) $(SHELLCMX): INCLUDES += -I src/tools
MARCHE Claude's avatar
MARCHE Claude committed
903 904 905 906 907 908

# build targets

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

909
bin/why3shell.opt: $(WHY3CMXA) $(SHELLCMX)
MARCHE Claude's avatar
MARCHE Claude committed
910 911 912
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

913
bin/why3shell.byte: $(WHY3CMA) $(SHELLCMO)
MARCHE Claude's avatar
MARCHE Claude committed
914 915 916 917 918 919 920 921 922 923 924
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

# depend and clean targets

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

depend: $(SHELLDEP)

925 926
uninstall-bin::
	rm -f $(TOOLDIR)/why3shell$(EXE)
MARCHE Claude's avatar
MARCHE Claude committed
927

928 929
install-bin::
	$(MKDIR_P) $(TOOLDIR)
MARCHE Claude's avatar
MARCHE Claude committed
930 931 932 933
	$(INSTALL) bin/why3shell.@OCAMLBEST@ $(TOOLDIR)/why3shell$(EXE)

install_local:: bin/why3shell

MARCHE Claude's avatar
MARCHE Claude committed
934

935 936 937
##############
# Coq plugin
##############
938

939
ifeq (@enable_coq_tactic@,yes)
940

941
COQPGENERATED = src/coq-tactic/why3tac.ml
942

943
COQP_FILES = why3tac
944

945
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
946

947 948 949
COQPDEP = $(addsuffix .dep, $(COQPMODULES))
COQPCMO = $(addsuffix .cmo, $(COQPMODULES))
COQPCMX = $(addsuffix .cmx, $(COQPMODULES))
950

Guillaume Melquiond's avatar
Guillaume Melquiond committed
951
COQPTREES = engine interp intf kernel lib library ltac parsing pretyping printing proofs tactics toplevel vernac plugins/ltac
952
COQPINCLUDES = -I src/coq-tactic -I $(COQCAMLPLIB) $(addprefix -I @COQLIB@/, $(COQPTREES)) @ZIPINCLUDE@
953

954
$(COQPDEP): DEPFLAGS += -I src/coq-tactic
955
$(COQPCMO) $(COQPCMX): INCLUDES += $(COQPINCLUDES)
956 957
$(COQPCMO) $(COQPCMX): BFLAGS += -rectypes
$(COQPCMX): OFLAGS += -rectypes