Makefile.in 66.5 KB
Newer Older
1 2 3
####################################################################
#                                                                  #
#  The Why3 Verification Platform   /   The Why3 Development Team  #
4
#  Copyright 2010-2014   --   INRIA - CNRS - Paris-Sud University  #
5 6 7 8 9 10
#                                                                  #
#  This software is distributed under the terms of the GNU Lesser  #
#  General Public License version 2.1, with the special exception  #
#  on linking described in file LICENSE.                           #
#                                                                  #
####################################################################
11

12 13 14 15 16 17
VERBOSEMAKE ?= @enable_verbose_make@

ifeq ($(VERBOSEMAKE),yes)
  QUIET =
else
  QUIET = yes
18 19
endif

20
# install the binaries
21
DESTDIR =
22

23
prefix	    = @prefix@
24 25 26 27 28
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@

BINDIR  = $(DESTDIR)@bindir@
LIBDIR  = $(DESTDIR)@libdir@
29
DATADIR = $(DESTDIR)@datarootdir@
30
MANDIR  = $(DESTDIR)@mandir@
31
TOOLDIR = $(LIBDIR)/why3/commands
32

Andrei Paskevich's avatar
Andrei Paskevich committed
33
# OS specific stuff
34
EXE   = @EXE@
35 36

# other variables
37
CC        = @CC@
38 39 40 41 42 43 44
OCAMLC    = @OCAMLC@
OCAMLOPT  = @OCAMLOPT@
OCAMLDEP  = @OCAMLDEP@
OCAMLLEX  = @OCAMLLEX@
OCAMLYACC = @OCAMLYACC@
OCAMLDOC  = @OCAMLDOC@
OCAMLLIB  = @OCAMLLIB@
45
OCAMLINSTALLLIB  = $(DESTDIR)@OCAMLINSTALLLIB@
46 47
OCAMLBEST = @OCAMLBEST@
OCAMLVERSION = @OCAMLVERSION@
48 49
COQC      = @COQC@
COQDEP    = @COQDEP@
50
CAMLP5O   = @CAMLP5O@
MARCHE Claude's avatar
MARCHE Claude committed
51
FRAMAC_LIBDIR = $(DESTDIR)@FRAMAC_LIBDIR@
52

53
DEPFLAGS  = -slash -I lib/why3
54
ifeq (@OCAMLBEST@,opt)
55
DEPFLAGS += -native
56 57
endif

58
RUBBER = @RUBBER@
59
HEVEA = @HEVEA@
60
HACHA = @HACHA@
61
EMACS = @EMACS@
62

63
#PSVIEWER  = @PSVIEWER@
Andrei Paskevich's avatar
Andrei Paskevich committed
64
#PDFVIEWER = @PDFVIEWER@
65

66
INCLUDES = @ZIPINCLUDE@
67 68
OFLAGS = -w Aer-41-44-45 -dtypes -g -I lib/why3 $(INCLUDES)
BFLAGS = -w Aer-41-44-45 -dtypes -g -I lib/why3 $(INCLUDES)
69 70 71

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

73
ifeq (@enable_profiling@,yes)
74 75 76
OFLAGS += -g -p
endif

77 78
# external libraries common to all binaries

79
EXTOBJS =
80
EXTLIBS = str unix nums dynlink @ZIPLIB@
81 82 83

EXTCMA	= $(addsuffix .cma,$(EXTLIBS)) $(addsuffix .cmo,$(EXTOBJS))
EXTCMXA = $(addsuffix .cmxa,$(EXTLIBS)) $(addsuffix .cmx,$(EXTOBJS))
84

85 86
TARGET_EMACS = share/emacs/why3.elc

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
87 88 89
###############
# main target
###############
90

91 92 93 94
all: @OCAMLBEST@
plugins: plugins.@OCAMLBEST@
opt: plugins.opt
byte: plugins.byte
Francois Bobot's avatar
Francois Bobot committed
95

96 97 98 99 100
ifeq (@enable_local@,yes)
all: install_local
endif

.PHONY: byte opt clean depend all install install_local install_no_local
101
.PHONY: plugins plugins.byte plugins.opt
102

103 104 105
##############
# Why3 library
##############
106

107
LIBGENERATED = src/util/config.ml \
108
	       src/util/rc.ml src/util/lexlib.ml src/parser/lexer.ml \
109 110
	       src/parser/parser.mli src/parser/parser.ml \
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
111 112
	       src/driver/driver_lexer.ml \
               src/session/compress.ml src/session/xml.ml \
113
	       lib/ocaml/why3__BigInt_compat.ml
114

115 116
LIB_UTIL = config bigInt util opt lists strings \
	   extmap extset exthtbl weakhtbl \
117
	   hashcons stdlib exn_printer pp debug loc lexlib print_tree \
118
	   cmdline warning sysutil rc plugin bigInt number pqueue
119

120 121
LIB_CORE = ident ty term pattern decl theory \
	   task pretty dterm env trans printer
122

123
LIB_DRIVER = call_provers driver_ast driver_parser driver_lexer driver \
124
	     whyconf autodetection
125

126 127
LIB_PARSER = ptree glob parser typing lexer

128
LIB_TRANSFORM = simplify_formula inlining split_goal induction \
129
		eliminate_definition eliminate_algebraic \
130
		eliminate_inductive eliminate_let eliminate_if \
131 132 133 134
		libencoding discriminate encoding encoding_select \
		encoding_guards_full encoding_tags_full \
		encoding_guards encoding_tags encoding_twin \
		encoding_sort simplify_array filter_trigger \
135
		introduction abstraction close_epsilon lift_epsilon \
136
		eliminate_epsilon \
137
		eval_match instantiate_predicate smoke_detector
138

139
LIB_PRINTER = alt_ergo why3printer smtv1 smtv2 coq pvs isabelle \
140
	      simplify gappa cvc3 yices mathematica
141

142
LIB_WHYML = mlw_ty mlw_expr mlw_decl mlw_pretty mlw_wp mlw_module \
143
	    mlw_dexpr mlw_typing mlw_driver mlw_ocaml \
144
	    mlw_main mlw_interp
145 146

LIBMODULES =  $(addprefix src/util/, $(LIB_UTIL)) \
147 148
	      $(addprefix src/core/, $(LIB_CORE)) \
	      $(addprefix src/driver/, $(LIB_DRIVER)) \
149
	      $(addprefix src/parser/, $(LIB_PARSER)) \
150
	      $(addprefix src/transform/, $(LIB_TRANSFORM)) \
François Bobot's avatar
François Bobot committed
151
	      $(addprefix src/printer/, $(LIB_PRINTER)) \
152
	      $(addprefix src/whyml/, $(LIB_WHYML))
153

154 155
LIB_SESSION = compress xml termcode session session_tools session_scheduler

156 157
LIBSESSIONMODULES = $(addprefix src/session/, $(LIB_SESSION))

158
LIBDIRS = util core driver parser transform printer whyml
159
LIBINCLUDES = $(addprefix -I src/, $(LIBDIRS))
MARCHE Claude's avatar
MARCHE Claude committed
160

161
LIBSESSIONDIRS = session
162 163
LIBSESSIONINCLUDES = $(addprefix -I src/, $(LIBSESSIONDIRS))

164
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
165 166
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
167

168 169 170 171
LIBSESSIONDEP = $(addsuffix .dep, $(LIBSESSIONMODULES))
LIBSESSIONCMO = $(addsuffix .cmo, $(LIBSESSIONMODULES))
LIBSESSIONCMX = $(addsuffix .cmx, $(LIBSESSIONMODULES))

172
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
173
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
174
$(LIBCMX): OFLAGS += -for-pack Why3
175

176 177 178 179
$(LIBSESSIONDEP): DEPFLAGS += $(LIBSESSIONINCLUDES)
$(LIBSESSIONCMO) $(LIBSESSIONCMX): INCLUDES += $(LIBSESSIONINCLUDES)
$(LIBSESSIONCMX): OFLAGS += -for-pack Why3session

180
$(LIBDEP): $(LIBGENERATED)
181
$(LIBSESSIONDEP): $(LIBGENERATED)
182

183 184 185 186
# Zarith

ifeq (@enable_zarith@,yes)

187
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_zarith.ml
188
	cp lib/ocaml/why3__BigInt_zarith.ml $@
189 190 191

else

192
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_num.ml
193
	cp lib/ocaml/why3__BigInt_num.ml $@
194 195 196

endif

197
clean::
198
	rm -f lib/ocaml/why3__BigInt_compat.ml
199

200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
# 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

clean::
	rm -f src/session/compress.ml

217
# build targets
218

219 220
byte: lib/why3/why3.cma
opt:  lib/why3/why3.cmxa
221

222
lib/why3/why3.cma: lib/why3/why3.cmo
Andrei Paskevich's avatar
Andrei Paskevich committed
223 224
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) -a $(BFLAGS) -o $@ $^
225

226
lib/why3/why3.cmxa: lib/why3/why3.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
227 228
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) -a $(OFLAGS) -o $@ $^
229

230
lib/why3/why3.cmo: $(LIBCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
231 232
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
233

234
lib/why3/why3.cmx: $(LIBCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
235 236
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -pack -o $@ $^
237

238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
byte: lib/why3/why3session.cma
opt:  lib/why3/why3session.cmxa

lib/why3/why3session.cma: lib/why3/why3session.cmo
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) -a $(BFLAGS) -o $@ $^

lib/why3/why3session.cmxa: lib/why3/why3session.cmx
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) -a $(OFLAGS) -o $@ $^

lib/why3/why3session.cmo: $(LIBSESSIONCMO)
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^

lib/why3/why3session.cmx: $(LIBSESSIONCMX)
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -pack -o $@ $^

257
# clean and depend
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
258

259
ifneq "$(MAKECMDGOALS)" "clean"
260
include $(LIBDEP) $(LIBSESSIONDEP)
261
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
262

263
depend: $(LIBDEP) $(LIBSESSIONDEP)
264

Andrei Paskevich's avatar
Andrei Paskevich committed
265
LIBSDIRS = src $(addprefix src/, $(LIBDIRS))
266 267
LIBCLEAN = $(addsuffix /*.cm[iox], $(LIBSDIRS)) \
	   $(addsuffix /*.annot, $(LIBSDIRS)) \
268 269
	   $(addsuffix /*.output, $(LIBSDIRS)) \
	   $(addsuffix /*.automaton, $(LIBSDIRS)) \
270
	   $(addsuffix /*.dep, $(LIBSDIRS)) \
271 272 273 274 275
	   $(addsuffix /*.o, $(LIBSDIRS)) \
	   $(addsuffix /*~, $(LIBSDIRS))

clean::
	rm -f $(LIBCLEAN) $(LIBGENERATED)
276
	rm -f lib/why3/why3.cm* lib/why3/why3.[ao]
277

278 279 280
###############
# installation
###############
281

Kate's avatar
Kate committed
282 283
clean_old_install::
	rm -rf $(LIBDIR)/why3
MARCHE Claude's avatar
MARCHE Claude committed
284
	rm -rf $(DATADIR)/why3
285
	rm -rf $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
286

287

288
ifeq ($(EMACS),no)
289
install_no_local:: clean_old_install
290 291 292
else
install_no_local:: clean_old_install $(TARGET_EMACS)
endif
293
	mkdir -p $(BINDIR)
Kate's avatar
Kate committed
294
	mkdir -p $(LIBDIR)/why3
295
	mkdir -p $(TOOLDIR)
296
	mkdir -p $(DATADIR)/why3
297
	mkdir -p $(DATADIR)/why3/images
298 299
	mkdir -p $(DATADIR)/why3/images/boomy
	mkdir -p $(DATADIR)/why3/images/fatcow
300
	mkdir -p $(DATADIR)/why3/vim
301
	mkdir -p $(DATADIR)/why3/lang
302
	mkdir -p $(DATADIR)/why3/theories
303
	mkdir -p $(DATADIR)/why3/modules/mach
304
	mkdir -p $(DATADIR)/why3/drivers
305
	mkdir -p $(DATADIR)/emacs/site-lisp/
306
	cp -f theories/*.why $(DATADIR)/why3/theories
307
	cp -f modules/*.mlw $(DATADIR)/why3/modules
308
	cp -f modules/mach/*.mlw $(DATADIR)/why3/modules/mach
309
	cp -f drivers/*.drv drivers/*.gen $(DATADIR)/why3/drivers
310
	cp -f share/provers-detection-data.conf $(DATADIR)/why3/
311
	cp -f share/images/icons.rc $(DATADIR)/why3/images
312
	cp -f share/images/*.png $(DATADIR)/why3/images
313 314
	cp -f share/images/boomy/*.png $(DATADIR)/why3/images/boomy
	cp -f share/images/fatcow/*.png $(DATADIR)/why3/images/fatcow
315
	cp -f share/why3session.dtd $(DATADIR)/why3
316
	cp -rf share/javascript $(DATADIR)/why3/javascript
317 318
	cp -f share/vim/why3.vim $(DATADIR)/why3/vim/why3.vim
	cp -f share/lang/why3.lang $(DATADIR)/why3/lang/why3.lang
319

MARCHE Claude's avatar
MARCHE Claude committed
320
install_no_local_lib::
321
	mkdir -p $(OCAMLINSTALLLIB)/why3
322
	cp -f lib/why3/why3.cm* lib/why3/why3.[ao] \
323
		lib/why3/META $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
324

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

MARCHE Claude's avatar
MARCHE Claude committed
334 335
install-all: install install-lib

Kate's avatar
Kate committed
336 337 338 339 340 341
##################
# Uninstallation
##################

uninstall: clean_old_install

342 343 344 345 346 347 348
##################
# Why3 emacs mode
##################

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

Kate's avatar
Kate committed
349 350 351 352 353 354 355 356 357 358 359 360 361
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::
	cp -f share/emacs/why3.el $(DATADIR)/emacs/site-lisp/why3.el
ifneq ($(EMACS),no)
	cp -f share/emacs/why3.elc $(DATADIR)/emacs/site-lisp/why3.elc
endif


362
##################
363
# Why3 plugins
364 365
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
366
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
367 368
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
		plugins/parser/dimacs.ml \
369

370
PLUG_PARSER = genequlin dimacs
371
PLUG_PRINTER =
372
PLUG_TRANSFORM =
373
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
374

375
PLUGINS = genequlin dimacs tptp
376

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

379 380
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
381

382 383 384 385 386 387 388 389 390 391
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

392 393
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
394
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
395
	      $(TPTPMODULES)
396

397
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
398 399 400
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
401
PLUGDIRS = parser printer transform tptp
402 403
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

404
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
405 406
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

407 408
$(PLUGDEP): $(PLUGGENERATED)

409 410 411 412 413
LIBPLUGCMO =  $(addsuffix .cmo,  $(addprefix lib/plugins/, $(PLUGINS)))
LIBPLUGCMXS = $(addsuffix .cmxs, $(addprefix lib/plugins/, $(PLUGINS)))

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
414 415

lib/plugins/%.cmxs: plugins/parser/%.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
416
	$(if $(QUIET),@echo 'Linking  $@' &&) \
417 418 419 420 421 422 423
	    $(OCAMLOPT) $(OFLAGS) -shared -o $@ $<

lib/plugins/%.cmo: plugins/parser/%.cmo
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $<

lib/plugins/%.cmxs: plugins/printer/%.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
424
	$(if $(QUIET),@echo 'Linking  $@' &&) \
425 426 427 428 429 430 431
	    $(OCAMLOPT) $(OFLAGS) -shared -o $@ $<

lib/plugins/%.cmo: plugins/printer/%.cmo
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $<

lib/plugins/%.cmxs: plugins/transform/%.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
432
	$(if $(QUIET),@echo 'Linking  $@' &&) \
433 434 435 436 437 438
	    $(OCAMLOPT) $(OFLAGS) -shared -o $@ $<

lib/plugins/%.cmo: plugins/transform/%.cmo
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $<

439
lib/plugins/tptp.cmxs: $(TPTPCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
440
	$(if $(QUIET),@echo 'Linking  $@' &&) \
441
	    $(OCAMLOPT) $(OFLAGS) -shared -o $@ $^
442

443
lib/plugins/tptp.cmo: $(TPTPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
444
	$(if $(QUIET),@echo 'Linking  $@' &&) \
445
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
446 447 448 449 450 451

PLUGSDIRS = plugins $(addprefix plugins/, $(PLUGDIRS))
PLUGCLEAN = $(addsuffix /*.cm[iox], $(PLUGSDIRS)) \
	    $(addsuffix /*.annot, $(PLUGSDIRS)) \
	    $(addsuffix /*.output, $(PLUGSDIRS)) \
	    $(addsuffix /*.automaton, $(PLUGSDIRS)) \
452
	    $(addsuffix /*.dep, $(PLUGSDIRS)) \
453 454 455
	    $(addsuffix /*.o, $(PLUGSDIRS)) \
	    $(addsuffix /*~, $(PLUGSDIRS))

456 457 458 459 460 461
# depend and clean targets

ifneq "$(MAKECMDGOALS)" "clean"
include $(PLUGDEP)
endif

462
depend: $(PLUGDEP)
463

464 465 466 467 468 469
clean::
	rm -f $(PLUGCLEAN) $(PLUGGENERATED)
	rm -f lib/plugins/*

install_no_local::
	mkdir -p $(LIBDIR)/why3/plugins
470
	cp -f $(foreach f,$(LIBPLUGCMO) $(LIBPLUGCMXS),$(wildcard $(f))) $(LIBDIR)/why3/plugins
471

472 473 474
#################################
# Old Why3 command, to be removed
#################################
475

476 477
src/tools/why3contraption.cmo: lib/why3/why3.cma
src/tools/why3contraption.cmx: lib/why3/why3.cmxa
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
478

479 480
byte: bin/why3contraption.byte
opt:  bin/why3contraption.opt
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
481

482 483 484 485 486 487 488 489
bin/why3contraption.opt: lib/why3/why3.cmxa src/tools/why3contraption.cmx
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

bin/why3contraption.byte: lib/why3/why3.cma src/tools/why3contraption.cmo
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

Kate's avatar
Kate committed
490
clean_old_install::
491
	rm -f $(BINDIR)/why3contraption$(EXE)
Kate's avatar
Kate committed
492

493
install_no_local::
494
	cp -f bin/why3contraption.@OCAMLBEST@ $(BINDIR)/why3contraption$(EXE)
495

496
install_local:: bin/why3 bin/why3contraption
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
497

498
ifneq "$(MAKECMDGOALS)" "clean"
499
include src/tools/why3contraption.dep
500 501
endif

502
depend: src/tools/why3contraption.dep
503

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
504
clean::
505 506 507 508 509 510 511
	rm -f src/tools/why3contraption.cm[iox] src/tools/why3contraption.annot src/tools/why3contraption.o src/tools/why3contraption.dep
	rm -f bin/why3contraption.byte bin/why3contraption.opt bin/why3contraption

###############
# Why3 commands
###############

512
TOOLS_BIN = why3config why3execute why3extract why3prove why3realize why3replay
513
TOOLS_FILES = main $(TOOLS_BIN)
514 515 516 517 518 519 520 521 522 523

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

524 525 526
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

527
bin/why3.opt: lib/why3/why3.cmxa src/tools/main.cmx
528 529 530
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

531
bin/why3.byte: lib/why3/why3.cma src/tools/main.cmo
532 533
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
534

535 536 537 538 539 540 541 542
bin/why3config.opt: lib/why3/why3.cmxa src/tools/why3config.cmx
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

bin/why3config.byte: lib/why3/why3.cma src/tools/why3config.cmo
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

543
bin/why3execute.opt: lib/why3/why3.cmxa src/tools/why3execute.cmx
544 545 546
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

547
bin/why3execute.byte: lib/why3/why3.cma src/tools/why3execute.cmo
548 549 550
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

551
bin/why3extract.opt: lib/why3/why3.cmxa src/tools/why3extract.cmx
552 553 554
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

555
bin/why3extract.byte: lib/why3/why3.cma src/tools/why3extract.cmo
556 557 558
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

559
bin/why3prove.opt: lib/why3/why3.cmxa src/tools/why3prove.cmx
560 561 562
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

563
bin/why3prove.byte: lib/why3/why3.cma src/tools/why3prove.cmo
564 565 566
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

567
bin/why3realize.opt: lib/why3/why3.cmxa src/tools/why3realize.cmx
568 569 570
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

571
bin/why3realize.byte: lib/why3/why3.cma src/tools/why3realize.cmo
572 573 574
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

575
bin/why3replay.opt: lib/why3/why3.cmxa lib/why3/why3session.cmxa src/tools/why3replay.cmx
576 577 578
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

579
bin/why3replay.byte: lib/why3/why3.cma lib/why3/why3session.cma src/tools/why3replay.cmo
580 581 582
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

Kate's avatar
Kate committed
583
clean_old_install::
584
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE)) $(BINDIR)/why3$(EXE)
Kate's avatar
Kate committed
585

586
install_no_local::
587
	cp -f bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
588
	cp -f bin/why3config.@OCAMLBEST@  $(TOOLDIR)/why3config$(EXE)
589 590 591
	cp -f bin/why3execute.@OCAMLBEST@ $(TOOLDIR)/why3execute$(EXE)
	cp -f bin/why3extract.@OCAMLBEST@ $(TOOLDIR)/why3extract$(EXE)
	cp -f bin/why3prove.@OCAMLBEST@   $(TOOLDIR)/why3prove$(EXE)
592
	cp -f bin/why3realize.@OCAMLBEST@ $(TOOLDIR)/why3realize$(EXE)
593 594 595
	cp -f bin/why3replay.@OCAMLBEST@  $(TOOLDIR)/why3replay$(EXE)

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

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

600
ifneq "$(MAKECMDGOALS)" "clean"
601
include $(TOOLSDEP)
602 603
endif

604
depend: $(TOOLSDEP)
605

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
606
clean::
607
	rm -f src/tools/main.cm[iox] src/tools/main.annot src/tools/main.o src/tools/main.dep
608
	rm -f src/tools/why3config.cm[iox] src/tools/why3config.annot src/tools/why3config.o src/tools/why3config.dep
609
	rm -f src/tools/why3execute.cm[iox] src/tools/why3execute.annot src/tools/why3execute.o src/tools/why3execute.dep
610
	rm -f src/tools/why3extract.cm[iox] src/tools/why3extract.annot src/tools/why3extract.o src/tools/why3extract.dep
611
	rm -f src/tools/why3prove.cm[iox] src/tools/why3prove.annot src/tools/why3prove.o src/tools/why3prove.dep
612
	rm -f src/tools/why3realize.cm[iox] src/tools/why3realize.annot src/tools/why3realize.o src/tools/why3realize.dep
613
	rm -f src/tools/why3replay.cm[iox] src/tools/why3replay.annot src/tools/why3replay.o src/tools/why3replay.dep
614 615 616
	rm -f $(addprefix bin/,$(TOOLS_BIN))
	rm -f $(TOOLS_BIN:%=bin/%.byte) $(TOOLS_BIN:%=bin/%.opt)
	rm -f bin/why3.byte bin/why3.opt bin/why3
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
617

618 619 620
##############
# test targets
##############
621

622 623
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
624

625 626
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
627

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

631 632
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
633

634
%.type: %.mlw bin/why3ide.opt
635
	bin/why3.opt --type-only $*.mlw
636

637 638 639 640
##########
# gallery
##########

641
# we export exactly the programs that have a why3session.xml file
642 643 644

.PHONY: gallery

645 646
gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
Andrei Paskevich's avatar
Andrei Paskevich committed
647
	@for x in examples/*/why3session.xml ; do \
648 649
	  d=`dirname $$x`; \
	  f=`basename $$d`; \
650
	  why3 session html $$x; \
651 652
	  echo "exporting $$f"; \
	  mkdir -p $(GALLERYDIR)/$$f; \
653
	  cp examples/$$f.mlw examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
654
	  rm -f $(GALLERYDIR)/$$f/$$f.zip; \
Andrei Paskevich's avatar
Andrei Paskevich committed
655
	  cd examples/; \
656
	  zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f; \
657
	  cd ..; \
658
	done
659

660 661 662 663 664
%-gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
	x=$*/why3session.xml; \
	d=`dirname $$x`; \
	f=`basename $$d`; \
665
	why3 session html $$x; \
666 667
	echo "exporting $$f"; \
	mkdir -p $(GALLERYDIR)/$$f; \
668 669
	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; \
670
	cp examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
671 672
	rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	cd examples/; \
673
	zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f
674

MARCHE Claude's avatar
MARCHE Claude committed
675 676 677 678 679 680 681 682
########
# XML DTD validation
########

.PHONY: xml-validate

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

686 687 688 689 690
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
691 692 693 694
###############
# IDE
###############

695 696
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
697
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
698 699 700

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

701
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
702 703 704
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

705
$(IDEDEP): DEPFLAGS += -I src/ide
706
$(IDECMO) $(IDECMX): INCLUDES += -I src/ide
MARCHE Claude's avatar
MARCHE Claude committed
707

708
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
709

710 711
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
712

713
bin/why3ide.opt bin/why3ide.byte: INCLUDES += -I @LABLGTK2LIB@
714
bin/why3ide.opt bin/why3ide.byte: EXTLIBS += lablgtk lablgtksourceview2
MARCHE Claude's avatar
MARCHE Claude committed
715

716
bin/why3ide.opt: lib/why3/why3.cmxa lib/why3/why3session.cmxa src/ide/resetgc.o $(IDECMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
717
	$(if $(QUIET),@echo 'Linking  $@' &&) \
718
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
MARCHE Claude's avatar
MARCHE Claude committed
719

720
bin/why3ide.byte: lib/why3/why3.cma lib/why3/why3session.cma src/ide/resetgc.o $(IDECMO)
MARCHE Claude's avatar
MARCHE Claude committed
721
	$(if $(QUIET),@echo 'Linking  $@' &&) \
722
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) -custom $^
MARCHE Claude's avatar
MARCHE Claude committed
723

724
src/ide/resetgc.o: src/ide/resetgc.c
725 726
	$(if $(QUIET),@echo 'Ocamlc   $<' &&) \
	    $(OCAMLC) -c -ccopt "-Wall -o $@" $<
727

MARCHE Claude's avatar
MARCHE Claude committed
728 729
# depend and clean targets

730 731 732
ifneq "$(MAKECMDGOALS)" "clean"
include $(IDEDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
733

734
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
735 736

clean::
737
	rm -f src/ide/xml.ml
MARCHE Claude's avatar
MARCHE Claude committed
738
	rm -f src/ide/*.cm[iox] src/ide/*.o
739
	rm -f src/ide/*.annot src/ide/*.dep src/ide/*~
740
	rm -f bin/why3ide.byte bin/why3ide.opt bin/why3ide
MARCHE Claude's avatar
MARCHE Claude committed
741

Kate's avatar
Kate committed
742 743 744
clean_old_install::
	rm -f $(BINDIR)/why3ide$(EXE)

745
install_no_local::
746
	cp -f bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
747

748
install_local:: bin/why3ide
749

750
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
751

752 753 754 755
###############
# Session
###############

756 757
SESSION_FILES = why3session_lib why3session_copy why3session_info	\
		why3session_latex why3session_html why3session_rm	\
758
		why3session_output why3session_run why3session_csv	\
759
		why3session_main
760 761 762

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

763
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
764 765 766
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

767
$(SESSIONDEP): DEPFLAGS += -I src/why3session
768 769 770 771 772 773 774
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

775
bin/why3session.opt: lib/why3/why3.cmxa lib/why3/why3session.cmxa $(SESSIONCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
776
	$(if $(QUIET),@echo 'Linking  $@' &&) \
777
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
778

779
bin/why3session.byte: lib/why3/why3.cma lib/why3/why3session.cma $(SESSIONCMO)
780
	$(if $(QUIET),@echo 'Linking  $@' &&) \
781
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
782 783 784

# depend and clean targets

785 786 787
ifneq "$(MAKECMDGOALS)" "clean"
include $(SESSIONDEP)
endif
788

789
depend: $(SESSIONDEP)
790 791

clean::
792 793
	rm -f src/why3session/*.cm[iox] src/why3session/*.o
	rm -f src/why3session/*.annot src/why3session/*.dep src/why3session/*~
794 795
	rm -f bin/why3session.byte bin/why3session.opt bin/why3session

Kate's avatar
Kate committed
796 797 798
clean_old_install::
	rm -f $(BINDIR)/why3session$(EXE)

799
install_no_local::
800
	cp -f bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
801

802
install_local:: bin/why3session
803

MARCHE Claude's avatar
MARCHE Claude committed
804

805 806 807
##############
# Coq plugin
##############
808

809
ifeq (@enable_coq_tactic@,yes)
810

Claude Marche's avatar
Claude Marche committed
811
COQPGENERATED = src/coq-tactic/coqCompat.ml src/coq-tactic/g_why3tac.ml
812

Claude Marche's avatar
Claude Marche committed
813
COQP_FILES = coqCompat why3tac g_why3tac
814

815
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
816

817 818 819
COQPDEP = $(addsuffix .dep, $(COQPMODULES))
COQPCMO = $(addsuffix .cmo, $(COQPMODULES))
COQPCMX = $(addsuffix .cmx, $(COQPMODULES))
820

821
COQPTREES = kernel lib interp parsing proofs pretyping tactics library toplevel
822
COQPINCLUDES = -I src/coq-tactic -I +camlp5 $(addprefix -I @COQLIB@/, $(COQPTREES)) @ZIPINCLUDE@
823

824
$(COQPDEP): DEPFLAGS += -I src/coq-tactic
825
$(COQPCMO) $(COQPCMX): INCLUDES += $(COQPINCLUDES)
826 827
$(COQPCMO) $(COQPCMX): BFLAGS += -rectypes
$(COQPCMX): OFLAGS += -rectypes
828

829
$(COQPDEP): $(COQPGENERATED)
830

831 832
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
833

834 835
src/coq-tactic/coqCompat.ml: src/coq-tactic/coqCompat@coq_compat_version@.ml
	cp -f $< $@
836

837
lib/coq-tactic/why3tac.cmxs: lib/why3/why3.cmxa $(COQPCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
838
	$(if $(QUIET),@echo 'Linking  $@' &&) \
839
	    $(OCAMLOPT) $(OFLAGS) -o $@ -shared $^
840

841
lib/coq-tactic/why3tac.cma: lib/why3/why3.cma $(COQPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
842
	$(if $(QUIET),@echo 'Linking  $@' &&) \
843
	    $(OCAMLC) -a $(BFLAGS) -o $@ $^
844

845
src/coq-tactic/g_why3tac.ml: src/coq-tactic/g_why3tac.ml4
Andrei Paskevich's avatar
Andrei Paskevich committed
846 847
	$(if $(QUIET),@echo 'Camlp5   $<' &&) \
	    $(CAMLP5O) pr_o.cmo @COQLIB@/parsing/grammar.cma -impl $^ -o $@
848

849
src/coq-tactic/.why3-vo-byte: lib/coq-tactic/Why3.v lib/coq-tactic/why3tac.cma
Andrei Paskevich's avatar
Andrei Paskevich committed
850
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
851
	    WHY3CONFIG="" $(COQC) -byte -I lib/coq-tactic/ $< && \
852
	    touch src/coq-tactic/.why3-vo-byte
853

854
src/coq-tactic/.why3-vo-opt: lib/coq-tactic/Why3.v lib/coq-tactic/why3tac.cmxs
Andrei Paskevich's avatar
Andrei Paskevich committed
855
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
856
	    WHY3CONFIG="" $(COQC) -opt -I lib/coq-tactic/ $< && \
857
	    touch src/coq-tactic/.why3-vo-opt
858

859
# depend and clean targets
Andrei Paskevich's avatar
Andrei Paskevich committed
860

861
ifneq "$(MAKECMDGOALS)" "clean"
862
include $(COQPDEP)
863
endif
864

865
depend: $(COQPDEP)
866 867

clean::
868 869 870 871 872
	rm -f src/coq-tactic/*.cm[iox] src/coq-tactic/*.o
	rm -f lib/coq-tactic/*.cma lib/coq-tactic/*.cmxs
	rm -f lib/coq-tactic/*.vo lib/coq-tactic/*.glob
	rm -f src/coq-tactic/*.annot src/coq-tactic/*.dep src/coq-tactic/*~
	rm -f src/coq-tactic/.why3-vo-*
873
	rm -f $(COQPGENERATED)
874

875
install_no_local::
876 877
	mkdir -p $(LIBDIR)/why3/coq-tactic
	cp -f lib/coq-tactic/* $(LIBDIR)/why3/coq-tactic
878

879 880 881 882 883 884 885 886
endif

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

ifeq (@enable_coq_libs@,yes)

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

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

894
COQLIBS_REAL_FILES = Abs ExpLog FromInt MinMax PowerInt Real RealInfix Square Trigonometry
895 896
COQLIBS_REAL = $(addprefix lib/coq/real/, $(COQLIBS_REAL_FILES))

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

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

903
COQLIBS_MAP_FILES = Map Occ MapPermut MapInjection
904 905
COQLIBS_MAP = $(addprefix lib/coq/map/, $(COQLIBS_MAP_FILES))

906
COQLIBS_LIST_FILES = List Length Mem Nth NthLength HdTl NthHdTl Append NthLengthAppend Reverse HdTlNoOpt NthNoOpt RevAppend Combine Distinct NumOcc Permut
907 908 909 910 911
COQLIBS_LIST = $(addprefix lib/coq/list/, $(COQLIBS_LIST_FILES))

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

912
ifeq (@enable_coq_fp_libs@,yes)
913
COQLIBS_FP_FILES = Rounding SingleFormat Single DoubleFormat Double
914 915 916
COQLIBS_FP_ALL_FILES = GenFloat $(COQLIBS_FP_FILES)
COQLIBS_FP = $(addprefix lib/coq/floating_point/, $(COQLIBS_FP_ALL_FILES))
endif
917

918
COQLIBS_FILES = lib/coq/BuiltIn $(COQLIBS_INT) $(COQLIBS_BOOL) $(COQLIBS_REAL) $(COQLIBS_NUMBER) $(COQLIBS_SET) $(COQLIBS_MAP) $(COQLIBS_LIST) $(COQLIBS_OPTION) $(COQLIBS_FP)
919 920 921

COQV  = $(addsuffix .v,  $(COQLIBS_FILES))
COQVO = $(addsuffix .vo, $(COQLIBS_FILES))
922
COQVD = $(addsuffix .vd, $(COQLIBS_FILES))
923 924

%.vo: %.v
Andrei Paskevich's avatar
Andrei Paskevich committed
925 926
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
	    $(COQC) -R lib/coq Why3 $<
927 928

%.vd: %.v
Andrei Paskevich's avatar
Andrei Paskevich committed
929 930
	$(if $(QUIET),@echo 'Coqdep   $<' &&) \
	    $(COQDEP) -slash -R lib/coq Why3 $< > $@
931

932 933 934
drivers/coq-realizations.aux: Makefile
	$(if $(QUIET),@echo 'Generate $@' &&) \
	(echo "(* generated automatically at compilation time *)"; \
Andrei Paskevich's avatar
Andrei Paskevich committed
935
	echo 'theory BuiltIn meta "realized_theory" "BuiltIn", "" end'; \
Andrei Paskevich's avatar
Andrei Paskevich committed
936
	for f in $(COQLIBS_INT_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
937
	echo 'theory int.'"$$f"' meta "realized_theory" "int.'"$$f"'", "" end'; done; \
938 939
	for f in $(COQLIBS_BOOL_FILES); do \
	echo 'theory bool.'"$$f"' meta "realized_theory" "bool.'"$$f"'", "" end'; done; \
Andrei Paskevich's avatar
Andrei Paskevich committed
940
	for f in $(COQLIBS_REAL_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
941
	echo 'theory real.'"$$f"' meta "realized_theory" "real.'"$$f"'", "" end'; done; \
942
	for f in $(COQLIBS_NUMBER_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
943
	echo 'theory number.'"$$f"' meta "realized_theory" "number.'"$$f"'", "" end'; done; \
944
	for f in $(COQLIBS_SET_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
945
	echo 'theory set.'"$$f"' meta "realized_theory" "set.'"$$f"'", "" end'; done; \
946 947
	for f in $(COQLIBS_MAP_FILES); do \
	echo 'theory map.'"$$f"' meta "realized_theory" "map.'"$$f"'", "" end'; done; \
948 949 950 951
	for f in $(COQLIBS_LIST_FILES); do \
	echo 'theory list.'"$$f"' meta "realized_theory" "list.'"$$f"'", "" end'; done; \
	for f in $(COQLIBS_OPTION_FILES); do \
	echo 'theory option.'"$$f"' meta "realized_theory" "option.'"$$f"'", "" end'; done; \
Andrei Paskevich's avatar
Andrei Paskevich committed
952
	for f in $(COQLIBS_FP_FILES); do \
Andrei Paskevich's avatar
Andrei Paskevich committed
953
	echo 'theory floating_point.'"$$f"' meta "realized_theory" "floating_point.'"$$f"'", "" end'; done; \
954
	) > $@
955

956
opt byte: $(COQVO)
957 958 959

install_no_local::
	mkdir -p $(LIBDIR)/why3/coq
960
	cp lib/coq/BuiltIn.vo $(LIBDIR)/why3/coq/
961
	mkdir -p $(LIBDIR)/why3/coq/int
962
	cp $(addsuffix .vo, $(COQLIBS_INT)) $(LIBDIR)/why3/coq/int/
963 964
	mkdir -p $(LIBDIR)/why3/coq/bool
	cp $(addsuffix .vo, $(COQLIBS_BOOL)) $(LIBDIR)/why3/coq/bool/
965
	mkdir -p $(LIBDIR)/why3/coq/real
966
	cp $(addsuffix .vo, $(COQLIBS_REAL)) $(LIBDIR)/why3/coq/real/
967 968
	mkdir -p $(LIBDIR)/why3/coq/number
	cp $(addsuffix .vo, $(COQLIBS_NUMBER)) $(LIBDIR)/why3/coq/number/
969 970
	mkdir -p $(LIBDIR)/why3/coq/set
	cp $(addsuffix .vo, $(COQLIBS_SET)) $(LIBDIR)/why3/coq/set/
971 972
	mkdir -p $(LIBDIR)/why3/coq/map
	cp $(addsuffix .vo, $(COQLIBS_MAP)) $(LIBDIR)/why3/coq/map/
973 974 975 976
	mkdir -p $(LIBDIR)/why3/coq/list
	cp $(addsuffix .vo, $(COQLIBS_LIST)) $(LIBDIR)/why3/coq/list/
	mkdir -p $(LIBDIR)/why3/coq/option
	cp $(addsuffix .vo, $(COQLIBS_OPTION)) $(LIBDIR)/why3/coq/option/
977 978
ifeq (@enable_coq_fp_libs@,yes)
	mkdir -p $(LIBDIR)/why3/coq/floating_point
979
	cp $(addsuffix .vo, $(COQLIBS_FP)) $(LIBDIR)/why3/coq/floating_point/
980
endif
981
	cp drivers/coq-realizations.aux $(DATADIR)/why3/drivers/
982

983
install_local:: $(COQVO) drivers/coq-realizations.aux
984

985
ifneq "$(MAKECMDGOALS)" "clean"
986
ifneq "$(MAKECMDGOALS:update-coq%=update-coq)" "update-coq"
987
include $(COQVD)
988
endif
989
endif
990

991
depend: $(COQVD)
992 993

clean::
994
	rm -f $(COQVO) $(COQVD) $(addsuffix .glob, $(COQLIBS_FILES))
995

996
update-coq: update-coq-int update-coq-bool update-coq-real update-coq-number update-coq-set update-coq-map update-coq-list update-coq-option update-coq-fp
997 998

update-coq-int: bin/why3 drivers/coq-realizations.aux theories/int.why
999
	for f in $(COQLIBS_INT_ALL_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L theories -D drivers/coq-realize.drv -T int.$$f -o lib/coq/int/; done
1000

1001
update-coq-bool: bin/why3 drivers/coq-realizations.aux theories/bool.why
1002
	for f in $(COQLIBS_BOOL_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L theories -D drivers/coq-realize.drv -T bool.$$f -o lib/coq/bool/; done
1003

1004
update-coq-real: bin/why3 drivers/coq-realizations.aux theories/real.why
1005
	for f in $(COQLIBS_REAL_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L theories -D drivers/coq-realize.drv -T real.$$f -o lib/coq/real/; done
1006 1007

update-coq-number: bin/why3 drivers/coq-realizations.aux theories/number.why
1008
	for f in $(COQLIBS_NUMBER_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L theories -D drivers/coq-realize.drv -T number.$$f -o lib/coq/number/; done
1009 1010

update-coq-set: bin/why3 drivers/coq-realizations.aux theories/set.why
1011
	for f in $(COQLIBS_SET_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L theories -D drivers/coq-realize.drv -T set.$$f -o lib/coq/set/; done
1012

1013
update-coq-map: bin/why3 drivers/coq-realizations.aux theories/map.why
1014
	for f in $(COQLIBS_MAP_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L theories -D drivers/coq-realize.drv -T map.$$f -o lib/coq/map/; done
1015

1016
update-coq-list: bin/why3 drivers/coq-realizations.aux theories/list.why
1017
	for f in $(COQLIBS_LIST_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L theories -D drivers/coq-realize.drv -T list.$$f -o lib/coq/list/; done
1018 1019

update-coq-option: bin/why3 drivers/coq-realizations.aux theories/option.why
1020
	for f in $(COQLIBS_OPTION_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L theories -D drivers/coq-realize.drv -T option.$$f -o lib/coq/option/; done
1021

1022
update-coq-fp: bin/why3 drivers/coq-realizations.aux theories/floating_point.why
1023
	for f in $(COQLIBS_FP_FILES); do WHY3CONFIG="" bin/why3realize.@OCAMLBEST@ -L theories -D drivers/coq-realize.drv -T floating_point.$$f -o lib/coq/floating_point/; done
1024

1025 1026
else

1027 1028
drivers/coq-realizations.aux:
	echo "(* generated automatically at compilation time *)" > $@
1029

1030 1031 1032
install_no_local::
	cp drivers/coq-realizations.aux $(DATADIR)/why3/drivers/

1033
endif
1034

1035 1036 1037 1038 1039
opt byte: drivers/coq-realizations.aux

clean::
	rm -f drivers/coq-realizations.aux

Jean-Christophe's avatar
Jean-Christophe committed
1040 1041 1042 1043 1044 1045
####################
# PVS realizations
####################

ifeq (@enable_pvs_libs@,yes)

Jean-Christophe's avatar
Jean-Christophe committed
1046
PVSLIBS_INT_FILES = Int Abs MinMax ComputerDivision EuclideanDivision
Jean-Christophe's avatar
Jean-Christophe committed
1047 1048
PVSLIBS_INT = $(addprefix lib/pvs/int/, $(PVSLIBS_INT_FILES))

Jean-Christophe's avatar
Jean-Christophe committed
1049 1050 1051
PVSLIBS_REAL_FILES = Abs FromInt MinMax Real Square ExpLog Trigonometry \