Makefile.in 63.8 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 94 95
# - fatal:
#   5    Partially applied function: expression whose result has function
#        type and is ignored.
#   48   Implicit elimination of optional arguments.

96
WARNINGS = A-4-9-41-44-45-50@5@48
97

98 99
OFLAGS = -w $(WARNINGS) -dtypes -g -I lib/why3 $(INCLUDES)
BFLAGS = -w $(WARNINGS) -dtypes -g -I lib/why3 $(INCLUDES)
100 101 102

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

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

108 109 110 111 112
ifeq (@enable_bin_annot@,yes)
OFLAGS += -bin-annot
BFLAGS += -bin-annot
endif

113 114
# external libraries common to all binaries

115
EXTOBJS = @MENHIRLIB@
116
EXTLIBS = str unix nums dynlink @ZIPLIB@
117 118 119

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
120

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

124 125
TARGET_EMACS = share/emacs/why3.elc

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

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
128 129 130
###############
# main target
###############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
131

132 133 134 135
all: @OCAMLBEST@
plugins: plugins.@OCAMLBEST@
opt: plugins.opt
byte: plugins.byte
Francois Bobot's avatar
Francois Bobot committed
136

137 138 139 140 141
ifeq (@enable_local@,yes)
all: install_local
endif

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

Andrei Paskevich's avatar
Andrei Paskevich committed
144 145 146 147
CLEANDIRS =
CLEANLIBS =
GENERATED =

148 149 150
##############
# Why3 library
##############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
151

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

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

168
LIB_CORE = ident ty term pattern decl theory \
169
	   task pretty dterm env trans printer model_parser
170

171
LIB_DRIVER = call_provers driver_ast driver_parser driver_lexer driver \
172
	     whyconf autodetection \
173
             parse_smtv2_model_parser parse_smtv2_model_lexer parse_smtv2_model
174

175
LIB_MLW = ity expr dexpr pdecl pmodule
176

177 178
LIB_PARSER = ptree glob parser typing lexer

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

194
LIB_PRINTER = alt_ergo why3printer smtv1 smtv2 coq pvs isabelle \
195
	      simplify gappa cvc3 yices mathematica
196

197
LIB_WHYML = mlw_ty mlw_expr mlw_decl mlw_pretty mlw_wp mlw_module \
198
	    mlw_dexpr mlw_typing mlw_driver mlw_exec mlw_ocaml \
199
	    mlw_main mlw_interp
200

201 202 203
LIB_SESSION = compress xml termcode session session_tools strategy \
              strategy_parser session_scheduler

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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
217
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
218 219
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
220

Andrei Paskevich's avatar
Andrei Paskevich committed
221
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
222
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
223
$(LIBCMX): OFLAGS += -for-pack Why3
224

225 226
$(LIBDEP): $(LIBGENERATED)

227 228 229
# Zarith

ifeq (@enable_zarith@,yes)
230
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_zarith.ml
231
	cp lib/ocaml/why3__BigInt_zarith.ml $@
232
else
233
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_num.ml
234
	cp lib/ocaml/why3__BigInt_num.ml $@
235 236
endif

237 238 239 240 241 242 243 244 245 246
# 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

247 248 249 250 251
# hide deprecated warnings for strings

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

252
# build targets
253

254 255
byte: lib/why3/why3.cma
opt:  lib/why3/why3.cmxa
256

257 258
lib/why3/why3.cma: lib/why3/why3.cmo
lib/why3/why3.cmxa: lib/why3/why3.cmx
259

260
lib/why3/why3.cmo: $(LIBCMO)
261 262
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -pack -o $@ $^
263

264
lib/why3/why3.cmx: $(LIBCMX)
265 266
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -pack -o $@ $^
267

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

270
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
271
-include $(LIBDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
272
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
273

274
depend: $(LIBDEP)
275

Andrei Paskevich's avatar
Andrei Paskevich committed
276 277 278
CLEANDIRS += src $(addprefix src/, $(LIBDIRS))
CLEANLIBS += lib/why3/why3session lib/why3/why3
GENERATED += $(LIBGENERATED)
279

280 281 282
###############
# installation
###############
283

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
284 285
clean_old_install::
	rm -rf $(LIBDIR)/why3
MARCHE Claude's avatar
MARCHE Claude committed
286
	rm -rf $(DATADIR)/why3
287
	rm -rf $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
288

289

290
ifeq ($(EMACS),no)
291
install_no_local:: clean_old_install
292 293 294
else
install_no_local:: clean_old_install $(TARGET_EMACS)
endif
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
	$(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
	$(MKDIR_P) $(DATADIR)/emacs/site-lisp/
	$(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/
312 313
	for i in share/images/*.rc; do \
	     d=`basename $$i .rc`; \
314 315 316
	     $(INSTALL_DATA) $$i $(DATADIR)/why3/images; \
	     $(MKDIR_P) $(DATADIR)/why3/images/$$d; \
	     $(INSTALL_DATA) share/images/$$d/* $(DATADIR)/why3/images/$$d; \
317
	done
318 319 320 321 322
	$(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
323

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

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

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

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

uninstall: clean_old_install

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

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

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
353 354 355 356 357 358 359
clean_old_install::
	rm -f $(DATADIR)/emacs/site-lisp/why3.el
ifneq ($(EMACS),no)
	rm -f $(DATADIR)/emacs/site-lisp/why3.elc
endif

install_no_local::
360
	$(INSTALL_DATA) share/emacs/why3.el $(DATADIR)/emacs/site-lisp/why3.el
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
361
ifneq ($(EMACS),no)
362
	$(INSTALL_DATA) share/emacs/why3.elc $(DATADIR)/emacs/site-lisp/why3.elc
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
363 364 365
endif


366
##################
367
# Why3 plugins
368 369
##################

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

374
PLUG_PARSER = genequlin dimacs
375
PLUG_PRINTER =
376
PLUG_TRANSFORM =
377
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
378

379
PLUGINS = genequlin dimacs tptp
380

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

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

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

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

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

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

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

411 412
$(PLUGDEP): $(PLUGGENERATED)

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

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
418 419

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

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

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

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

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

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

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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
451 452
# depend and clean targets

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

457
depend: $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
458

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

install_no_local::
463 464
	$(MKDIR_P) $(LIBDIR)/why3/plugins
	$(INSTALL_DATA) $(wildcard $(LIBPLUGCMO) $(LIBPLUGCMXS)) $(LIBDIR)/why3/plugins
465

466 467 468 469
###############
# Why3 commands
###############

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

TOOLS_BIN = why3config why3execute why3extract why3prove \
	    why3realize why3replay why3wc

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

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
486 487
$(TOOLSDEP): $(TOOLSGENERATED)

488 489 490
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

Andrei Paskevich's avatar
Andrei Paskevich committed
491 492
bin/why3.opt: lib/why3/why3.cmxa src/tools/main.cmx
bin/why3.byte: lib/why3/why3.cma src/tools/main.cmo
493 494
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
495 496 497 498 499 500 501 502
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
503 504
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
505 506 507
bin/why3wc.opt: src/tools/why3wc.cmx
bin/why3wc.byte: src/tools/why3wc.cmo

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

512
install_no_local::
513 514 515 516 517 518 519 520
	$(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)
521 522

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

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

527 528 529 530 531 532 533 534 535 536 537
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

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

542
depend: $(TOOLSDEP)
543

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

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

550 551 552
##############
# test targets
##############
553

554 555
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
556

557 558
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
559

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

563 564
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
565

566
%.type: %.mlw bin/why3ide.opt
567
	bin/why3.opt --type-only $*.mlw
568

569 570 571 572
##########
# gallery
##########

573
# we export exactly the programs that have a why3session.xml file
574 575 576

.PHONY: gallery

577 578
gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
Andrei Paskevich's avatar
Andrei Paskevich committed
579
	@for x in examples/*/why3session.xml ; do \
580 581
	  d=`dirname $$x`; \
	  f=`basename $$d`; \
582
	  why3 session html $$x; \
583 584
	  echo "exporting $$f"; \
	  mkdir -p $(GALLERYDIR)/$$f; \
585
	  cp examples/$$f.mlw examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
586
	  rm -f $(GALLERYDIR)/$$f/$$f.zip; \
Andrei Paskevich's avatar
Andrei Paskevich committed
587
	  cd examples/; \
588
	  zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f; \
589
	  cd ..; \
590
	done
591

592 593 594 595 596
.PHONY: gallery-subs

GALLERYSUBS=avl

gallery-subs::
597
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
598 599 600 601 602 603 604 605 606 607 608
	@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


609 610 611 612 613
%-gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
	x=$*/why3session.xml; \
	d=`dirname $$x`; \
	f=`basename $$d`; \
614
	why3 session html $$d; \
615
	rm $$d/*.bak; \
616 617
	echo "exporting $$f"; \
	mkdir -p $(GALLERYDIR)/$$f; \
618 619
	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; \
620
	cp examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
621 622
	rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	cd examples/; \
623
	zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f
624

MARCHE Claude's avatar
MARCHE Claude committed
625 626 627 628 629 630 631 632
########
# XML DTD validation
########

.PHONY: xml-validate

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

636 637 638 639 640
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
641 642 643 644
###############
# IDE
###############

645 646
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
647
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
648 649 650

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

Andrei Paskevich's avatar
Andrei Paskevich committed
651
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
652 653 654
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

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

658
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
659

660 661
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
662

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

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

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

674
src/ide/resetgc.o: src/ide/resetgc.c
675 676
	$(SHOW) 'Ocamlc   $<'
	$(HIDE)$(OCAMLC) -c -ccopt "-Wall -o $@" $<
677

MARCHE Claude's avatar
MARCHE Claude committed
678 679
# depend and clean targets

680
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
681
-include $(IDEDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
682
endif
MARCHE Claude's avatar
MARCHE Claude committed
683

Andrei Paskevich's avatar
Andrei Paskevich committed
684
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
685

Andrei Paskevich's avatar
Andrei Paskevich committed
686
CLEANDIRS += src/ide
MARCHE Claude's avatar
MARCHE Claude committed
687

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
688 689 690
clean_old_install::
	rm -f $(BINDIR)/why3ide$(EXE)

691
install_no_local::
692
	$(INSTALL) bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
693

694
install_local:: bin/why3ide
695

696
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
697

698 699 700 701
###############
# Session
###############

Andrei Paskevich's avatar
Andrei Paskevich committed
702 703 704
SESSION_FILES = why3session_lib why3session_copy why3session_info \
		why3session_latex why3session_html why3session_rm \
		why3session_output why3session_run why3session_csv \
705
		why3session_main
706 707 708

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

Andrei Paskevich's avatar
Andrei Paskevich committed
709
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
710 711 712
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
713
$(SESSIONDEP): DEPFLAGS += -I src/why3session
714 715 716 717 718 719 720
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

721
bin/why3session.opt: lib/why3/why3.cmxa $(SESSIONCMX)
722 723
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
724

725
bin/why3session.byte: lib/why3/why3.cma $(SESSIONCMO)
726 727
	$(SHOW) 'Linking  $@'
	$(HIDE)$(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
728 729 730

# depend and clean targets

731
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
732
-include $(SESSIONDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
733
endif
734

Andrei Paskevich's avatar
Andrei Paskevich committed
735
depend: $(SESSIONDEP)
736

Andrei Paskevich's avatar
Andrei Paskevich committed
737
CLEANDIRS += src/why3session
738

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
739 740 741
clean_old_install::
	rm -f $(BINDIR)/why3session$(EXE)

742
install_no_local::
743
	$(INSTALL) bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
744

745
install_local:: bin/why3session
746

MARCHE Claude's avatar
MARCHE Claude committed
747

748 749 750
##############
# Coq plugin
##############
751

Andrei Paskevich's avatar
Andrei Paskevich committed
752
ifeq (@enable_coq_tactic@,yes)
753

754
COQPGENERATED = src/coq-tactic/why3tac.ml
755

756
COQP_FILES = why3tac
757

758
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
759

760 761 762
COQPDEP = $(addsuffix .dep, $(COQPMODULES))
COQPCMO = $(addsuffix .cmo, $(COQPMODULES))
COQPCMX = $(addsuffix .cmx, $(COQPMODULES))
763

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

767
$(COQPDEP): DEPFLAGS += -I src/coq-tactic
768
$(COQPCMO) $(COQPCMX): INCLUDES += $(COQPINCLUDES)
Andrei Paskevich's avatar
Andrei Paskevich committed
769 770
$(COQPCMO) $(COQPCMX): BFLAGS += -rectypes
$(COQPCMX): OFLAGS += -rectypes
771

772
$(COQPDEP): $(COQPGENERATED)
773

774 775
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
776

777 778 779 780
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@)
781
lib/coq-tactic/why3tac.cma:  BFLAGS += $(addsuffix .cmo,  @MENHIRLIB@)
782

783 784
lib/coq-tactic/why3tac.cmxs: lib/why3/why3.cmxa $(COQPCMX)
lib/coq-tactic/why3tac.cma: lib/why3/why3.cma $(COQPCMO)
785

786
src/coq-tactic/why3tac.ml: src/coq-tactic/why3tac.ml4
787 788
	$(SHOW) 'Camlp    $<'
	$(HIDE)$(COQCAMLP) pr_dump.cmo @COQPPLIBS@ pa_macro.cmo -D@coq_compat_version@ -impl $^ -o $@
789

790
src/coq-tactic/.why3-vo-byte: lib/coq-tactic/Why3.v lib/coq/BuiltIn.vo lib/coq-tactic/why3tac.cma
791 792
	$(SHOW) 'Coqc     $<'
	$(HIDE)WHY3CONFIG="" $(COQC) -byte -R lib/coq-tactic Why3 -R lib/coq Why3 $< && \
793
	    touch src/coq-tactic/.why3-vo-byte
794

795
src/coq-tactic/.why3-vo-opt: lib/coq-tactic/Why3.v lib/coq/BuiltIn.vo lib/coq-tactic/why3tac.cmxs
796 797
	$(SHOW) 'Coqc     $<'
	$(HIDE)WHY3CONFIG="" $(COQC) -opt -R lib/coq-tactic Why3 -R lib/coq Why3 $< && \
798
	    touch src/coq-tactic/.why3-vo-opt
799

800
# depend and clean targets
Andrei Paskevich's avatar
Andrei Paskevich committed
801

802
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
803
-include $(COQPDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
804
endif
805

806
depend: $(COQPDEP)
807

Andrei Paskevich's avatar
Andrei Paskevich committed
808 809 810 811
CLEANDIRS += src/coq-tactic
CLEANLIBS += lib/coq-tactic/why3tac
GENERATED += $(COQPGENERATED)

812
clean::
813 814
	rm -f lib/coq-tactic/*.vo lib/coq-tactic/*.glob
	rm -f src/coq-tactic/.why3-vo-*
815

816
install_no_local::
817 818
	$(MKDIR_P) $(LIBDIR)/why3/coq-tactic
	$(INSTALL_DATA) lib/coq-tactic/* $(LIBDIR)/why3/coq-tactic
819

820 821 822 823 824 825
endif

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

826 827
ifeq (@enable_coq_support@,yes)

828 829
ifeq (@enable_coq_libs@,yes)

830 831 832 833 834 835 836 837 838 839 840 841 842 843 844

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)


845
COQLIBS_INT_FILES = Abs ComputerDivision Div2 EuclideanDivision Int MinMax Power NumOf
846 847
COQLIBS_INT_ALL_FILES = Exponentiation $(COQLIBS_INT_FILES)
COQLIBS_INT = $(addprefix lib/coq/int/, $(COQLIBS_INT_ALL_FILES))
848

849 850 851
COQLIBS_BOOL_FILES = Bool
COQLIBS_BOOL = $(addprefix lib/coq/bool/, $(COQLIBS_BOOL_FILES))

852
COQLIBS_REAL_FILES = Abs ExpLog FromInt MinMax PowerInt PowerReal Real RealInfix Square Trigonometry
853 854
COQLIBS_REAL = $(addprefix lib/coq/real/, $(COQLIBS_REAL_FILES))

855
COQLIBS_NUMBER_FILES = Divisibility Gcd Parity Prime Coprime
856 857
COQLIBS_NUMBER = $(addprefix lib/coq/number/, $(COQLIBS_NUMBER_FILES))

858 859 860
COQLIBS_SET_FILES = Set
COQLIBS_SET = $(addprefix lib/coq/set/, $(COQLIBS_SET_FILES))

MARCHE Claude's avatar
MARCHE Claude committed
861
COQLIBS_MAP_FILES = Map Const Occ MapPermut MapInjection
862 863
COQLIBS_MAP = $(addprefix lib/coq/map/, $(COQLIBS_MAP_FILES))

864
COQLIBS_LIST_FILES = List Length Mem Nth NthLength HdTl NthHdTl Append NthLengthAppend Reverse HdTlNoOpt NthNoOpt RevAppend Combine Distinct NumOcc Permut
865 866 867 868 869
COQLIBS_LIST = $(addprefix lib/coq/list/, $(COQLIBS_LIST_FILES))

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