Makefile.in 67.5 KB
Newer Older
Andrei Paskevich's avatar
Andrei Paskevich committed
1
2
3
####################################################################
#                                                                  #
#  The Why3 Verification Platform   /   The Why3 Development Team  #
Andrei Paskevich's avatar
Andrei Paskevich committed
4
#  Copyright 2010-2016   --   INRIA - CNRS - Paris-Sud University  #
Andrei Paskevich's avatar
Andrei Paskevich committed
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
DEPFLAGS  = -slash -I lib/why3
66
ifeq (@OCAMLBEST@,opt)
67
68
# the semantics of the -native flag changed in ocaml 4.03.0
#DEPFLAGS += -native
69
70
endif

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

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

79
INCLUDES = @ZIPINCLUDE@ @MENHIRINCLUDE@
80
81
82
83
84
85
86
87
88
89

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

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

101
102
OFLAGS = -w $(WARNINGS) -dtypes -g -I lib/why3 $(INCLUDES)
BFLAGS = -w $(WARNINGS) -dtypes -g -I lib/why3 $(INCLUDES)
103
104
105

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

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

111
112
113
114
115
ifeq (@enable_bin_annot@,yes)
OFLAGS += -bin-annot
BFLAGS += -bin-annot
endif

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

119
120
# external libraries common to all binaries

121
EXTOBJS = @MENHIRLIB@
122
EXTLIBS = str unix nums dynlink @ZIPLIB@
123
124
125

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

127
128
INSTALLED_LIB_EXTS = a cma cmx cmi cmxa cmxs
COMPILED_LIB_EXTS = $(INSTALLED_LIB_EXTS) o cmo cmt cmti annot dep conflicts
Andrei Paskevich's avatar
Andrei Paskevich committed
129

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

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
132
133
134
###############
# main target
###############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
135

136
137
138
139
all: @OCAMLBEST@
plugins: plugins.@OCAMLBEST@
opt: plugins.opt
byte: plugins.byte
Francois Bobot's avatar
Francois Bobot committed
140

141
142
143
144
145
ifeq (@enable_local@,yes)
all: install_local
endif

.PHONY: byte opt clean depend all install install_local install_no_local
146
.PHONY: plugins plugins.byte plugins.opt
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
147

Andrei Paskevich's avatar
Andrei Paskevich committed
148
149
150
151
CLEANDIRS =
CLEANLIBS =
GENERATED =

152
153
154
##############
# Why3 library
##############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
155

156
LIBGENERATED = src/util/config.ml \
157
	       src/util/rc.ml src/util/lexlib.ml src/parser/lexer.ml \
158
159
	       src/parser/parser.mli src/parser/parser.ml \
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
160
	       src/driver/driver_lexer.ml \
161
162
               src/driver/parse_smtv2_model_parser.mli src/driver/parse_smtv2_model_parser.ml \
               src/driver/parse_smtv2_model_lexer.ml \
163
	       src/session/compress.ml src/session/xml.ml \
164
	       src/session/strategy_parser.ml \
165
	       lib/ocaml/why3__BigInt_compat.ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
166

167
168
LIB_UTIL = config bigInt util opt lists strings \
	   extmap extset exthtbl weakhtbl \
169
	   hashcons stdlib exn_printer pp json debug loc lexlib print_tree \
170
	   cmdline warning sysutil rc plugin bigInt number pqueue
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
171

172
LIB_CORE = ident ty term pattern decl theory \
173
	   task pretty dterm env trans printer model_parser
174

175
LIB_DRIVER = prove_client call_provers driver_ast driver_parser driver_lexer driver \
176
	     whyconf autodetection \
177
             parse_smtv2_model_parser parse_smtv2_model_lexer parse_smtv2_model
178

179
LIB_MLW = ity expr dexpr pdecl pmodule
180

181
182
LIB_PARSER = ptree glob parser typing lexer

183
LIB_TRANSFORM = simplify_formula inlining split_goal induction \
184
		detect_polymorphism \
185
		reduction_engine compute \
186
		eliminate_definition eliminate_algebraic \
187
		eliminate_inductive eliminate_let eliminate_if \
188
189
190
191
		libencoding discriminate encoding encoding_select \
		encoding_guards_full encoding_tags_full \
		encoding_guards encoding_tags encoding_twin \
		encoding_sort simplify_array filter_trigger \
192
		introduction abstraction close_epsilon lift_epsilon \
193
		eliminate_epsilon intro_projections_counterexmp \
194
		intro_vc_vars_counterexmp prepare_for_counterexmp \
MARCHE Claude's avatar
MARCHE Claude committed
195
		eval_match instantiate_predicate smoke_detector \
196
		induction_pr prop_curry
197

198
LIB_PRINTER = cntexmp_printer alt_ergo why3printer smtv1 smtv2 coq pvs isabelle \
199
	      simplify gappa cvc3 yices mathematica
200

201
LIB_WHYML = mlw_ty mlw_expr mlw_decl mlw_pretty mlw_wp mlw_module \
202
	    mlw_dexpr mlw_typing mlw_driver mlw_exec mlw_ocaml \
203
	    mlw_main mlw_interp
204

205
206
207
LIB_SESSION = compress xml termcode session session_tools strategy \
              strategy_parser session_scheduler

208
LIBMODULES =  $(addprefix src/util/, $(LIB_UTIL)) \
209
210
	      $(addprefix src/core/, $(LIB_CORE)) \
	      $(addprefix src/driver/, $(LIB_DRIVER)) \
211
	      $(addprefix src/mlw/, $(LIB_MLW)) \
212
	      $(addprefix src/parser/, $(LIB_PARSER)) \
213
	      $(addprefix src/transform/, $(LIB_TRANSFORM)) \
François Bobot's avatar
François Bobot committed
214
	      $(addprefix src/printer/, $(LIB_PRINTER)) \
215
216
	      $(addprefix src/whyml/, $(LIB_WHYML)) \
	      $(addprefix src/session/, $(LIB_SESSION))
217

218
LIBDIRS = util core driver mlw parser transform printer whyml session
219
LIBINCLUDES = $(addprefix -I src/, $(LIBDIRS))
MARCHE Claude's avatar
MARCHE Claude committed
220

Andrei Paskevich's avatar
Andrei Paskevich committed
221
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
222
223
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
224

Andrei Paskevich's avatar
Andrei Paskevich committed
225
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
226
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
227
$(LIBCMX): OFLAGS += -for-pack Why3
228

229
230
$(LIBDEP): $(LIBGENERATED)

231
232
233
# Zarith

ifeq (@enable_zarith@,yes)
234
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_zarith.ml
235
	cp lib/ocaml/why3__BigInt_zarith.ml $@
236
else
237
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_num.ml
238
	cp lib/ocaml/why3__BigInt_num.ml $@
239
240
endif

241
242
243
244
245
246
247
248
249
250
# 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

251
252
253
254
255
# hide deprecated warnings for strings

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

256
# build targets
257

258
259
byte: lib/why3/why3.cma
opt:  lib/why3/why3.cmxa
260

261
262
lib/why3/why3.cma: lib/why3/why3.cmo
lib/why3/why3.cmxa: lib/why3/why3.cmx
263

264
lib/why3/why3.cmo: $(LIBCMO)
265
266
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $^
267

268
lib/why3/why3.cmx: $(LIBCMX) lib/why3/why3.cmo
269
	$(SHOW) 'Linking  $@'
270
	$(HIDE)$(OCAMLOPT) $(OFLAGS) $(CMIHACK) -pack -o $@ $(filter %.cmx, $^)
271

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

274
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
275
-include $(LIBDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
276
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
277

278
depend: $(LIBDEP)
279

Andrei Paskevich's avatar
Andrei Paskevich committed
280
281
282
CLEANDIRS += src $(addprefix src/, $(LIBDIRS))
CLEANLIBS += lib/why3/why3session lib/why3/why3
GENERATED += $(LIBGENERATED)
283

284
285
286
###############
# installation
###############
287

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
288
289
clean_old_install::
	rm -rf $(LIBDIR)/why3
MARCHE Claude's avatar
MARCHE Claude committed
290
	rm -rf $(DATADIR)/why3
291
	rm -rf $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
292

293
294

install_no_local:: clean_old_install
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
	$(MKDIR_P) $(BINDIR)
	$(MKDIR_P) $(LIBDIR)/why3
	$(MKDIR_P) $(TOOLDIR)
	$(MKDIR_P) $(DATADIR)/why3
	$(MKDIR_P) $(DATADIR)/why3/images
	$(MKDIR_P) $(DATADIR)/why3/vim
	$(MKDIR_P) $(DATADIR)/why3/lang
	$(MKDIR_P) $(DATADIR)/why3/theories
	$(MKDIR_P) $(DATADIR)/why3/modules/mach
	$(MKDIR_P) $(DATADIR)/why3/drivers
	$(INSTALL_DATA) theories/*.why $(DATADIR)/why3/theories
	$(INSTALL_DATA) modules/*.mlw $(DATADIR)/why3/modules
	$(INSTALL_DATA) modules/mach/*.mlw $(DATADIR)/why3/modules/mach
	$(INSTALL_DATA) drivers/*.drv drivers/*.gen $(DATADIR)/why3/drivers
	$(INSTALL_DATA) LICENSE $(DATADIR)/why3/
	$(INSTALL_DATA) share/provers-detection-data.conf $(DATADIR)/why3/
311
312
	for i in share/images/*.rc; do \
	     d=`basename $$i .rc`; \
313
314
315
	     $(INSTALL_DATA) $$i $(DATADIR)/why3/images; \
	     $(MKDIR_P) $(DATADIR)/why3/images/$$d; \
	     $(INSTALL_DATA) share/images/$$d/* $(DATADIR)/why3/images/$$d; \
316
	done
317
318
319
320
321
	$(INSTALL_DATA) share/images/*.png $(DATADIR)/why3/images
	$(INSTALL_DATA) share/why3session.dtd $(DATADIR)/why3
	$(INSTALL_DATA) share/Makefile.config $(DATADIR)/why3
	$(INSTALL_DATA) share/vim/why3.vim $(DATADIR)/why3/vim/why3.vim
	$(INSTALL_DATA) share/lang/why3.lang $(DATADIR)/why3/lang/why3.lang
322

MARCHE Claude's avatar
MARCHE Claude committed
323
install_no_local_lib::
324
325
	$(MKDIR_P) $(OCAMLINSTALLLIB)/why3
	$(INSTALL_DATA) $(wildcard $(addprefix lib/why3/why3., $(INSTALLED_LIB_EXTS))) \
326
		lib/why3/META $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
327

328
329
ifeq (@enable_local@,yes)
install install-lib:
330
331
	@echo "Why3 is configured in local installation mode."
	@echo "To install Why3, run ./configure --disable-local ; make ; make install"
332
else
MARCHE Claude's avatar
MARCHE Claude committed
333
install: clean_old_install install_no_local
MARCHE Claude's avatar
MARCHE Claude committed
334
install-lib: install_no_local_lib
335
336
endif

MARCHE Claude's avatar
MARCHE Claude committed
337
338
install-all: install install-lib

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
339
340
341
342
343
344
##################
# Uninstallation
##################

uninstall: clean_old_install

345
346
347
348
349
350
351
##################
# Why3 emacs mode
##################

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

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
352
353
354
355
356
clean_old_install::
	rm -f $(DATADIR)/emacs/site-lisp/why3.el
	rm -f $(DATADIR)/emacs/site-lisp/why3.elc

install_no_local::
357
	$(MKDIR_P) $(DATADIR)/emacs/site-lisp/
358
	$(INSTALL_DATA) share/emacs/why3.el $(DATADIR)/emacs/site-lisp/why3.el
359
ifeq (@enable_emacs_compilation@,yes)
360
	$(INSTALL_DATA) share/emacs/why3.elc $(DATADIR)/emacs/site-lisp/why3.elc
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
361
362
endif

363
ifeq (@enable_emacs_compilation@,yes)
364
all: share/emacs/why3.elc
365
366
endif

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
367

368
##################
369
# Why3 plugins
370
371
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
372
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
373
374
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
		plugins/parser/dimacs.ml \
375

376
PLUG_PARSER = genequlin dimacs
377
PLUG_PRINTER =
378
PLUG_TRANSFORM =
379
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
380

381
PLUGINS = genequlin dimacs tptp
382

Andrei Paskevich's avatar
Andrei Paskevich committed
383
TPTPMODULES = $(addprefix plugins/tptp/, $(PLUG_TPTP))
Andrei Paskevich's avatar
Andrei Paskevich committed
384

Andrei Paskevich's avatar
Andrei Paskevich committed
385
386
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
387

388
389
390
391
392
393
394
395
396
397
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

398
399
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
400
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
401
	      $(TPTPMODULES)
402

Andrei Paskevich's avatar
Andrei Paskevich committed
403
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
404
405
406
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
407
PLUGDIRS = parser printer transform tptp
408
409
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
410
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
411
412
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

413
414
$(PLUGDEP): $(PLUGGENERATED)

415
416
417
418
419
LIBPLUGCMO =  $(addsuffix .cmo,  $(addprefix lib/plugins/, $(PLUGINS)))
LIBPLUGCMXS = $(addsuffix .cmxs, $(addprefix lib/plugins/, $(PLUGINS)))

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
420
421

lib/plugins/%.cmxs: plugins/parser/%.cmx
422
423
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -shared -o $@ $<
424
425

lib/plugins/%.cmo: plugins/parser/%.cmo
426
427
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $<
428
429

lib/plugins/%.cmxs: plugins/printer/%.cmx
430
431
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -shared -o $@ $<
432
433

lib/plugins/%.cmo: plugins/printer/%.cmo
434
435
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $<
436
437

lib/plugins/%.cmxs: plugins/transform/%.cmx
438
439
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -shared -o $@ $<
440
441

lib/plugins/%.cmo: plugins/transform/%.cmo
442
443
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $<
444

Andrei Paskevich's avatar
Andrei Paskevich committed
445
lib/plugins/tptp.cmxs: $(TPTPCMX)
446
447
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -shared -o $@ $^
448

Andrei Paskevich's avatar
Andrei Paskevich committed
449
lib/plugins/tptp.cmo: $(TPTPCMO)
450
451
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $^
452

Andrei Paskevich's avatar
Andrei Paskevich committed
453
454
# depend and clean targets

455
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
456
-include $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
457
458
endif

459
depend: $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
460

Andrei Paskevich's avatar
Andrei Paskevich committed
461
462
CLEANDIRS += plugins $(addprefix plugins/, $(PLUGDIRS)) lib/plugins
GENERATED += $(PLUGGENERATED)
463
464

install_no_local::
465
466
	$(MKDIR_P) $(LIBDIR)/why3/plugins
	$(INSTALL_DATA) $(wildcard $(LIBPLUGCMO) $(LIBPLUGCMXS)) $(LIBDIR)/why3/plugins
467

468
469
470
471
###############
# Why3 commands
###############

Andrei Paskevich's avatar
Andrei Paskevich committed
472
473
474
475
476
TOOLSGENERATED = src/tools/why3wc.ml

TOOLS_BIN = why3config why3execute why3extract why3prove \
	    why3realize why3replay why3wc

Andrei Paskevich's avatar
Andrei Paskevich committed
477
TOOLS_FILES = main $(TOOLS_BIN)
478
479
480
481
482
483
484
485
486
487

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

Andrei Paskevich's avatar
Andrei Paskevich committed
488
489
$(TOOLSDEP): $(TOOLSGENERATED)

490
491
492
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

Andrei Paskevich's avatar
Andrei Paskevich committed
493
494
bin/why3.opt: lib/why3/why3.cmxa src/tools/main.cmx
bin/why3.byte: lib/why3/why3.cma src/tools/main.cmo
495
496
bin/why3config.opt: lib/why3/why3.cmxa src/tools/why3config.cmx
bin/why3config.byte: lib/why3/why3.cma src/tools/why3config.cmo
Andrei Paskevich's avatar
Andrei Paskevich committed
497
498
499
500
501
502
503
504
bin/why3execute.opt: lib/why3/why3.cmxa src/tools/why3execute.cmx
bin/why3execute.byte: lib/why3/why3.cma src/tools/why3execute.cmo
bin/why3extract.opt: lib/why3/why3.cmxa src/tools/why3extract.cmx
bin/why3extract.byte: lib/why3/why3.cma src/tools/why3extract.cmo
bin/why3prove.opt: lib/why3/why3.cmxa src/tools/why3prove.cmx
bin/why3prove.byte: lib/why3/why3.cma src/tools/why3prove.cmo
bin/why3realize.opt: lib/why3/why3.cmxa src/tools/why3realize.cmx
bin/why3realize.byte: lib/why3/why3.cma src/tools/why3realize.cmo
505
506
bin/why3replay.opt: lib/why3/why3.cmxa src/tools/why3replay.cmx
bin/why3replay.byte: lib/why3/why3.cma src/tools/why3replay.cmo
Andrei Paskevich's avatar
Andrei Paskevich committed
507
508
509
bin/why3wc.opt: src/tools/why3wc.cmx
bin/why3wc.byte: src/tools/why3wc.cmo

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
510
clean_old_install::
511
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE)) $(BINDIR)/why3$(EXE)
512
	rm -f $(BINDIR)/why3bench$(EXE) $(BINDIR)/why3replayer$(EXE)
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
513

514
install_no_local::
515
516
517
518
519
520
521
522
	$(INSTALL) bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
	$(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)
523
524

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

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

529
530
531
532
533
534
535
536
537
538
539
install_local:: share/drivers share/modules share/theories

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

share/modules:
	ln -snf ../modules share/modules

share/theories:
	ln -snf ../theories share/theories

540
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
541
-include $(TOOLSDEP)
542
543
endif

544
depend: $(TOOLSDEP)
545

Andrei Paskevich's avatar
Andrei Paskevich committed
546
547
548
CLEANDIRS += src/tools
GENERATED += $(TOOLSGENERATED)

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
549
clean::
Andrei Paskevich's avatar
Andrei Paskevich committed
550
	rm -f bin/why3*
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
551

552
553
554
##############
# test targets
##############
555

556
557
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
558

559
560
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
561

562
563
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
564

565
566
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
567

568
%.type: %.mlw bin/why3ide.opt
569
	bin/why3.opt --type-only $*.mlw
570

571
572
573
574
##############
# Why3server #
##############

575
576
577
578
579
580
581
582
SERVER_MODULES := logging arraylist options queue readbuf request \
		  writebuf server-unix server-win

CPULIM_MODULES := cpulimit-unix cpulimit-win

SERVER_O := $(addprefix src/server/, $(addsuffix .o, $(SERVER_MODULES)))

CPULIM_O := $(addprefix src/server/, $(addsuffix .o, $(CPULIM_MODULES)))
583

584
585
TOOLS = lib/why3server$(EXE) lib/why3cpulimit$(EXE)

586
all: $(TOOLS)
587

588
lib/why3server$(EXE): $(SERVER_O)
589
590
591
592
	$(CC) -Wall -o $@ $^

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

594
%.o: %.c
595
	$(CC) -Wall -O -g -o $@ -c $<
596
597

install_no_local::
598
599
600
601
	$(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
602
603

clean::
604
	rm -f $(SERVER_O) $(CPULIM_O) $(TOOLS)
605

606
607
608
609
##########
# gallery
##########

610
# we export exactly the programs that have a why3session.xml file
611
612
613

.PHONY: gallery

614
615
616
617
618
gallery:: gallery-simple gallery-subs

.PHONY: gallery-simple

gallery-simple::
619
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
Andrei Paskevich's avatar
Andrei Paskevich committed
620
	@for x in examples/*/why3session.xml ; do \
621
622
	  d=`dirname $$x`; \
	  f=`basename $$d`; \
623
	  why3 session html $$x; \
624
625
	  echo "exporting $$f"; \
	  mkdir -p $(GALLERYDIR)/$$f; \
626
	  cp examples/$$f.mlw examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
627
	  rm -f $(GALLERYDIR)/$$f/$$f.zip; \
Andrei Paskevich's avatar
Andrei Paskevich committed
628
	  cd examples/; \
629
	  zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f; \
630
	  cd ..; \
631
	done
632

633
634
.PHONY: gallery-subs

635
GALLERYSUBS=WP_revisited verifythis_2016_matrix_multiplication avl double_wp
636
637

gallery-subs::
638
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
639
640
641
642
643
644
645
646
647
648
649
	@for d in $(GALLERYSUBS) ; do \
	  echo "exporting examples/$$d"; \
	  rm -f $(GALLERYDIR)/$$d/$$d.zip; \
	  cd examples/$$d; \
	  why3 -L . doc --stdlib-url http://why3.lri.fr/stdlib/ *.mlw -o $(GALLERYDIR)/$$d; \
	  cd ..; \
	  zip -r $(GALLERYDIR)/$$d/$$d.zip $$d; \
	  cd ..; \
	done


650
651
652
653
654
%-gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
	x=$*/why3session.xml; \
	d=`dirname $$x`; \
	f=`basename $$d`; \
655
	why3 session html $$d; \
656
	rm $$d/*.bak; \
657
658
	echo "exporting $$f"; \
	mkdir -p $(GALLERYDIR)/$$f; \
659
660
	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; \
661
	cp examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
662
663
	rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	cd examples/; \
664
	zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f
665

MARCHE Claude's avatar
MARCHE Claude committed
666
667
668
669
670
671
672
673
########
# XML DTD validation
########

.PHONY: xml-validate

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

677
678
679
680
681
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
682
683
684
685
###############
# IDE
###############

686
687
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
688
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
689
690
691

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

Andrei Paskevich's avatar
Andrei Paskevich committed
692
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
693
694
695
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

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

699
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
700

701
702
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
703

704
bin/why3ide.opt bin/why3ide.byte: INCLUDES += -I @LABLGTK2LIB@
Andrei Paskevich's avatar
Andrei Paskevich committed
705
bin/why3ide.opt bin/why3ide.byte: EXTLIBS += lablgtk lablgtksourceview2
MARCHE Claude's avatar
MARCHE Claude committed
706

707
bin/why3ide.opt: lib/why3/why3.cmxa src/ide/resetgc.o $(IDECMX)
708
709
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
MARCHE Claude's avatar
MARCHE Claude committed
710

711
bin/why3ide.byte: lib/why3/why3.cma src/ide/resetgc.o $(IDECMO)
712
713
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) -custom $^
MARCHE Claude's avatar
MARCHE Claude committed
714

715
src/ide/resetgc.o: src/ide/resetgc.c
716
717
	$(SHOW) 'Ocamlc   $<'
	$(HIDE)$(OCAMLC) -c -ccopt "-Wall -o $@" $<
718

MARCHE Claude's avatar
MARCHE Claude committed
719
720
# depend and clean targets

721
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
722
-include $(IDEDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
723
endif
MARCHE Claude's avatar
MARCHE Claude committed
724

Andrei Paskevich's avatar
Andrei Paskevich committed
725
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
726

Andrei Paskevich's avatar
Andrei Paskevich committed
727
CLEANDIRS += src/ide
MARCHE Claude's avatar
MARCHE Claude committed
728

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
729
730
731
clean_old_install::
	rm -f $(BINDIR)/why3ide$(EXE)

732
install_no_local::
733
	$(INSTALL) bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
734

735
install_local:: bin/why3ide
736

737
endif
MARCHE Claude's avatar
d    
MARCHE Claude committed
738

739
740
741
742
###############
# Session
###############

Andrei Paskevich's avatar
Andrei Paskevich committed
743
744
745
SESSION_FILES = why3session_lib why3session_copy why3session_info \
		why3session_latex why3session_html why3session_rm \
		why3session_output why3session_run why3session_csv \
746
		why3session_main
747
748
749

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

Andrei Paskevich's avatar
Andrei Paskevich committed
750
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
751
752
753
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
754
$(SESSIONDEP): DEPFLAGS += -I src/why3session
755
756
757
758
759
760
761
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

762
bin/why3session.opt: lib/why3/why3.cmxa $(SESSIONCMX)
763
764
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
765

766
bin/why3session.byte: lib/why3/why3.cma $(SESSIONCMO)
767
768
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
769
770
771

# depend and clean targets

772
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
773
-include $(SESSIONDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
774
endif
775

Andrei Paskevich's avatar
Andrei Paskevich committed
776
depend: $(SESSIONDEP)
777

Andrei Paskevich's avatar
Andrei Paskevich committed
778
CLEANDIRS += src/why3session
779

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
780
781
782
clean_old_install::
	rm -f $(BINDIR)/why3session$(EXE)

783
install_no_local::
784
	$(INSTALL) bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
785

786
install_local:: bin/why3session
787

MARCHE Claude's avatar
MARCHE Claude committed
788

789
790
791
##############
# Coq plugin
##############
792

Andrei Paskevich's avatar
Andrei Paskevich committed
793
ifeq (@enable_coq_tactic@,yes)
794

795
COQPGENERATED = src/coq-tactic/why3tac.ml
796

797
COQP_FILES = why3tac
798

799
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
800

801
802
803
COQPDEP = $(addsuffix .dep, $(COQPMODULES))
COQPCMO = $(addsuffix .cmo, $(COQPMODULES))
COQPCMX = $(addsuffix .cmx, $(COQPMODULES))
804

805
COQPTREES = kernel interp intf lib library parsing pretyping proofs printing tactics toplevel
806
COQPINCLUDES = -I src/coq-tactic -I $(COQCAMLPLIB) $(addprefix -I @COQLIB@/, $(COQPTREES)) @ZIPINCLUDE@
807

808
$(COQPDEP): DEPFLAGS += -I src/coq-tactic
809
$(COQPCMO) $(COQPCMX): INCLUDES += $(COQPINCLUDES)
Andrei Paskevich's avatar
Andrei Paskevich committed
810
811
$(COQPCMO) $(COQPCMX): BFLAGS += -rectypes
$(COQPCMX): OFLAGS += -rectypes
812

813
$(COQPDEP): $(COQPGENERATED)
814

815
816
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
817

818
819
820
821
lib/coq-tactic/why3tac.cmxs: OFLAGS += $(addsuffix .cmxa, @ZIPLIB@)
lib/coq-tactic/why3tac.cmxs: OFLAGS += $(addsuffix .cmx,  @MENHIRLIB@)

lib/coq-tactic/why3tac.cma:  BFLAGS += $(addsuffix .cma,  @ZIPLIB@)
822
lib/coq-tactic/why3tac.cma:  BFLAGS += $(addsuffix .cmo,  @MENHIRLIB@)
823

824
825
lib/coq-tactic/why3tac.cmxs: lib/why3/why3.cmxa $(COQPCMX)
lib/coq-tactic/why3tac.cma: lib/why3/why3.cma $(COQPCMO)
826

827
src/coq-tactic/why3tac.ml: src/coq-tactic/why3tac.ml4
828
829
	$(SHOW) 'Camlp    $<'
	$(HIDE)$(COQCAMLP) pr_dump.cmo @COQPPLIBS@ pa_macro.cmo -D@coq_compat_version@ -impl $^ -o $@
830

831
src/coq-tactic/.why3-vo-byte: lib/coq-tactic/Why3.v lib/coq/BuiltIn.vo lib/coq-tactic/why3tac.cma
832
833
	$(SHOW) 'Coqc     $<'
	$(HIDE)WHY3CONFIG="" $(COQC) -byte -R lib/coq-tactic Why3 -R lib/coq Why3 $< && \
834
	    touch src/coq-tactic/.why3-vo-byte
835

836
src/coq-tactic/.why3-vo-opt: lib/coq-tactic/Why3.v lib/coq/BuiltIn.vo lib/coq-tactic/why3tac.cmxs
837
838
	$(SHOW) 'Coqc     $<'
	$(HIDE)WHY3CONFIG="" $(COQC) -opt -R lib/coq-tactic Why3 -R lib/coq Why3 $< && \
839
	    touch src/coq-tactic/.why3-vo-opt
840

841
# depend and clean targets
Andrei Paskevich's avatar
Andrei Paskevich committed
842

843
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
844
-include $(COQPDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
845
endif
846

847
depend: $(COQPDEP)
848

Andrei Paskevich's avatar
Andrei Paskevich committed
849
850
851
852
CLEANDIRS += src/coq-tactic
CLEANLIBS += lib/coq-tactic/why3tac
GENERATED += $(COQPGENERATED)

853
clean::
854
855
	rm -f lib/coq-tactic/*.vo lib/coq-tactic/*.glob
	rm -f src/coq-tactic/.why3-vo-*
856

857
install_no_local::
858
859
	$(MKDIR_P) $(LIBDIR)/why3/coq-tactic
	$(INSTALL_DATA) lib/coq-tactic/* $(LIBDIR)/why3/coq-tactic
860

861
862
863
864
865
866
endif

####################
# Coq realizations
####################

867
868
ifeq (@enable_coq_support@,yes)

869
870
ifeq (@enable_coq_libs@,yes)

871
872
873
874
875
876
877
878
879
880
881
882
883
884
885

COQVERSIONSPECIFIC=bv/BV_Gen.v

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)


886
COQLIBS_INT_FILES = Abs ComputerDivision Div2 EuclideanDivision Int MinMax Power NumOf
887
888
COQLIBS_INT_ALL_FILES = Exponentiation $(COQLIBS_INT_FILES)
COQLIBS_INT = $(addprefix lib/coq/int/, $(COQLIBS_INT_ALL_FILES))
889

890
891
892
COQLIBS_BOOL_FILES = Bool
COQLIBS_BOOL = $(addprefix lib/coq/bool/, $(COQLIBS_BOOL_FILES))

Clément Fumex's avatar
Clément Fumex committed
893
COQLIBS_REAL_FILES = Abs ExpLog FromInt MinMax PowerInt PowerReal Real RealInfix Square Trigonometry Truncate
894
895
COQLIBS_REAL = $(addprefix lib/coq/real/, $(COQLIBS_REAL_FILES))

896
COQLIBS_NUMBER_FILES = Divisibility Gcd Parity Prime Coprime
897
898
COQLIBS_NUMBER = $(addprefix lib/coq/number/, $(COQLIBS_NUMBER_FILES))

899
900
901
COQLIBS_SET_FILES = Set
COQLIBS_SET = $(addprefix lib/coq/set/, $(COQLIBS_SET_FILES))

MARCHE Claude's avatar
MARCHE Claude committed
902
COQLIBS_MAP_FILES = Map Const Occ MapPermut MapInjection