Makefile.in 59.9 KB
Newer Older
Andrei Paskevich's avatar
Andrei Paskevich committed
1 2 3
####################################################################
#                                                                  #
#  The Why3 Verification Platform   /   The Why3 Development Team  #
4
#  Copyright 2010-2015   --   INRIA - CNRS - Paris-Sud University  #
Andrei Paskevich's avatar
Andrei Paskevich committed
5 6 7 8
#                                                                  #
#  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.                           #
9
#                                                                  #
Andrei Paskevich's avatar
Andrei Paskevich committed
10
####################################################################
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
11

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

ifeq ($(VERBOSEMAKE),yes)
  QUIET =
else
  QUIET = yes
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
18 19
endif

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

Andrei Paskevich's avatar
Andrei Paskevich committed
33
# OS specific stuff
34
EXE   = @EXE@
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
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 51
COQCAMLP  = @COQCAMLP@
COQCAMLPLIB = @COQCAMLPLIB@
MARCHE Claude's avatar
MARCHE Claude committed
52
FRAMAC_LIBDIR = $(DESTDIR)@FRAMAC_LIBDIR@
53

54 55 56 57 58 59
ifeq (@enable_menhirLib@,yes)
MENHIR	  = @MENHIR@ --table
else
MENHIR	  = @MENHIR@
endif

60
DEPFLAGS  = -slash -I lib/why3
61
ifeq (@OCAMLBEST@,opt)
Andrei Paskevich's avatar
Andrei Paskevich committed
62
DEPFLAGS += -native
63 64
endif

65
RUBBER = @RUBBER@
66
HEVEA = @HEVEA@
67
HACHA = @HACHA@
68
EMACS = @EMACS@
69

70
#PSVIEWER  = @PSVIEWER@
Andrei Paskevich's avatar
Andrei Paskevich committed
71
#PDFVIEWER = @PDFVIEWER@
72

73
INCLUDES = @ZIPINCLUDE@ @MENHIRINCLUDE@
74 75
OFLAGS = -w Aer-41-44-45 -dtypes -g -I lib/why3 $(INCLUDES)
BFLAGS = -w Aer-41-44-45 -dtypes -g -I lib/why3 $(INCLUDES)
76 77 78

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

80
ifeq (@enable_profiling@,yes)
81 82 83
OFLAGS += -g -p
endif

84 85 86 87 88
ifeq (@enable_bin_annot@,yes)
OFLAGS += -bin-annot
BFLAGS += -bin-annot
endif

89 90
# external libraries common to all binaries

91
EXTOBJS = @MENHIRLIB@
92
EXTLIBS = str unix nums dynlink @ZIPLIB@
93 94 95

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
96

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

100 101
TARGET_EMACS = share/emacs/why3.elc

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
102 103 104
###############
# main target
###############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
105

106 107 108 109
all: @OCAMLBEST@
plugins: plugins.@OCAMLBEST@
opt: plugins.opt
byte: plugins.byte
Francois Bobot's avatar
Francois Bobot committed
110

111 112 113 114 115
ifeq (@enable_local@,yes)
all: install_local
endif

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

Andrei Paskevich's avatar
Andrei Paskevich committed
118 119 120 121
CLEANDIRS =
CLEANLIBS =
GENERATED =

122
install_local::
123 124 125
	ln -s -n -f ../drivers share/drivers
	ln -s -n -f ../modules share/modules
	ln -s -n -f ../theories share/theories
126

127 128 129
##############
# Why3 library
##############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
130

131
LIBGENERATED = src/util/config.ml \
132
	       src/util/rc.ml src/util/lexlib.ml src/parser/lexer.ml \
133 134
	       src/parser/parser.mli src/parser/parser.ml \
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
135
	       src/driver/driver_lexer.ml \
136
	       src/session/compress.ml src/session/xml.ml \
137
	       src/session/strategy_parser.ml \
138
	       lib/ocaml/why3__BigInt_compat.ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
139

140 141
LIB_UTIL = config bigInt util opt lists strings \
	   extmap extset exthtbl weakhtbl \
142
	   hashcons stdlib exn_printer pp debug loc lexlib print_tree \
143
	   cmdline warning sysutil rc plugin bigInt number pqueue
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
144

145 146
LIB_CORE = ident ty term pattern decl theory \
	   task pretty dterm env trans printer
147

148
LIB_DRIVER = call_provers driver_ast driver_parser driver_lexer driver \
149
	     whyconf autodetection
150

151
LIB_MLW = ity expr dexpr
152

153 154
LIB_PARSER = ptree glob parser typing lexer

155
LIB_TRANSFORM = simplify_formula inlining split_goal induction \
156
		detect_polymorphism \
157
		eliminate_definition eliminate_algebraic \
158
		eliminate_inductive eliminate_let eliminate_if \
159 160 161 162
		libencoding discriminate encoding encoding_select \
		encoding_guards_full encoding_tags_full \
		encoding_guards encoding_tags encoding_twin \
		encoding_sort simplify_array filter_trigger \
163
		introduction abstraction close_epsilon lift_epsilon \
164
		eliminate_epsilon \
MARCHE Claude's avatar
MARCHE Claude committed
165
		eval_match instantiate_predicate smoke_detector \
166
		reduction_engine compute induction_pr prop_curry
167

168
LIB_PRINTER = alt_ergo why3printer smtv1 smtv2 coq pvs isabelle \
169
	      simplify gappa cvc3 yices mathematica
170

171
LIB_WHYML = mlw_ty mlw_expr mlw_decl mlw_pretty mlw_wp mlw_module \
172
	    mlw_dexpr mlw_typing mlw_driver mlw_exec mlw_ocaml \
173
	    mlw_main mlw_interp
174

175 176 177
LIB_SESSION = compress xml termcode session session_tools strategy \
              strategy_parser session_scheduler

178
LIBMODULES =  $(addprefix src/util/, $(LIB_UTIL)) \
179 180
	      $(addprefix src/core/, $(LIB_CORE)) \
	      $(addprefix src/driver/, $(LIB_DRIVER)) \
181
	      $(addprefix src/mlw/, $(LIB_MLW)) \
182
	      $(addprefix src/parser/, $(LIB_PARSER)) \
183
	      $(addprefix src/transform/, $(LIB_TRANSFORM)) \
François Bobot's avatar
François Bobot committed
184
	      $(addprefix src/printer/, $(LIB_PRINTER)) \
185 186
	      $(addprefix src/whyml/, $(LIB_WHYML)) \
	      $(addprefix src/session/, $(LIB_SESSION))
187

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

Andrei Paskevich's avatar
Andrei Paskevich committed
191
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
192 193
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
194

Andrei Paskevich's avatar
Andrei Paskevich committed
195
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
196
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
197
$(LIBCMX): OFLAGS += -for-pack Why3
198

199 200
$(LIBDEP): $(LIBGENERATED)

201 202 203
# Zarith

ifeq (@enable_zarith@,yes)
204
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_zarith.ml
205
	cp lib/ocaml/why3__BigInt_zarith.ml $@
206
else
207
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_num.ml
208
	cp lib/ocaml/why3__BigInt_num.ml $@
209 210
endif

211 212 213 214 215 216 217 218 219 220
# 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

221
# build targets
222

223 224
byte: lib/why3/why3.cma
opt:  lib/why3/why3.cmxa
225

226
lib/why3/why3.cma: lib/why3/why3.cmo
Andrei Paskevich's avatar
Andrei Paskevich committed
227 228
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) -a $(BFLAGS) -o $@ $^
229

230
lib/why3/why3.cmxa: lib/why3/why3.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
231 232
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) -a $(OFLAGS) -o $@ $^
233

234
lib/why3/why3.cmo: $(LIBCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
235 236
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
237

238
lib/why3/why3.cmx: $(LIBCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
239 240
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -pack -o $@ $^
241

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

244
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
245
include $(LIBDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
246
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
247

248
depend: $(LIBDEP)
249

Andrei Paskevich's avatar
Andrei Paskevich committed
250 251 252
CLEANDIRS += src $(addprefix src/, $(LIBDIRS))
CLEANLIBS += lib/why3/why3session lib/why3/why3
GENERATED += $(LIBGENERATED)
253

254 255 256
###############
# installation
###############
257

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
258 259
clean_old_install::
	rm -rf $(LIBDIR)/why3
MARCHE Claude's avatar
MARCHE Claude committed
260
	rm -rf $(DATADIR)/why3
261
	rm -rf $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
262

263

264
ifeq ($(EMACS),no)
265
install_no_local:: clean_old_install
266 267 268
else
install_no_local:: clean_old_install $(TARGET_EMACS)
endif
269
	mkdir -p $(BINDIR)
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
270
	mkdir -p $(LIBDIR)/why3
271
	mkdir -p $(TOOLDIR)
272
	mkdir -p $(DATADIR)/why3
273
	mkdir -p $(DATADIR)/why3/images
274 275
	mkdir -p $(DATADIR)/why3/images/boomy
	mkdir -p $(DATADIR)/why3/images/fatcow
276
	mkdir -p $(DATADIR)/why3/vim
277
	mkdir -p $(DATADIR)/why3/lang
MARCHE Claude's avatar
MARCHE Claude committed
278
	mkdir -p $(DATADIR)/why3/theories
279
	mkdir -p $(DATADIR)/why3/modules/mach
MARCHE Claude's avatar
MARCHE Claude committed
280
	mkdir -p $(DATADIR)/why3/drivers
281
	mkdir -p $(DATADIR)/emacs/site-lisp/
MARCHE Claude's avatar
MARCHE Claude committed
282
	cp -f theories/*.why $(DATADIR)/why3/theories
283
	cp -f modules/*.mlw $(DATADIR)/why3/modules
284
	cp -f modules/mach/*.mlw $(DATADIR)/why3/modules/mach
Andrei Paskevich's avatar
Andrei Paskevich committed
285
	cp -f drivers/*.drv drivers/*.gen $(DATADIR)/why3/drivers
MARCHE Claude's avatar
MARCHE Claude committed
286
	cp -f LICENSE $(DATADIR)/why3/
287
	cp -f share/provers-detection-data.conf $(DATADIR)/why3/
288
	cp -f share/images/icons.rc $(DATADIR)/why3/images
289
	cp -f share/images/*.png $(DATADIR)/why3/images
MARCHE Claude's avatar
MARCHE Claude committed
290 291
	cp -f share/images/boomy/* $(DATADIR)/why3/images/boomy
	cp -f share/images/fatcow/* $(DATADIR)/why3/images/fatcow
292
	cp -f share/why3session.dtd $(DATADIR)/why3
293
	cp -f share/Makefile.config $(DATADIR)/why3
294
	cp -rf share/javascript $(DATADIR)/why3/javascript
295 296
	cp -f share/vim/why3.vim $(DATADIR)/why3/vim/why3.vim
	cp -f share/lang/why3.lang $(DATADIR)/why3/lang/why3.lang
297

MARCHE Claude's avatar
MARCHE Claude committed
298
install_no_local_lib::
299
	mkdir -p $(OCAMLINSTALLLIB)/why3
300
	cp -f $(wildcard $(addprefix lib/why3/why3., $(INSTALLED_LIB_EXTS))) \
301
		lib/why3/META $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
302

303 304
ifeq (@enable_local@,yes)
install install-lib:
305 306
	@echo "Why3 is configured in local installation mode."
	@echo "To install Why3, run ./configure --disable-local ; make ; make install"
307
else
MARCHE Claude's avatar
MARCHE Claude committed
308
install: clean_old_install install_no_local
MARCHE Claude's avatar
MARCHE Claude committed
309
install-lib: install_no_local_lib
310 311
endif

MARCHE Claude's avatar
MARCHE Claude committed
312 313
install-all: install install-lib

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
314 315 316 317 318 319
##################
# Uninstallation
##################

uninstall: clean_old_install

320 321 322 323 324 325 326
##################
# Why3 emacs mode
##################

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

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
327 328 329 330 331 332 333 334 335 336 337 338 339
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


340
##################
341
# Why3 plugins
342 343
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
344
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
345 346
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
		plugins/parser/dimacs.ml \
347

348
PLUG_PARSER = genequlin dimacs
349
PLUG_PRINTER =
350
PLUG_TRANSFORM =
351
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
352

353
PLUGINS = genequlin dimacs tptp
354

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

Andrei Paskevich's avatar
Andrei Paskevich committed
357 358
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
359

360 361 362 363 364 365 366 367 368 369
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

370 371
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
372
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
373
	      $(TPTPMODULES)
374

Andrei Paskevich's avatar
Andrei Paskevich committed
375
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
376 377 378
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
379
PLUGDIRS = parser printer transform tptp
380 381
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
382
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
383 384
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

385 386
$(PLUGDEP): $(PLUGGENERATED)

387 388 389 390 391
LIBPLUGCMO =  $(addsuffix .cmo,  $(addprefix lib/plugins/, $(PLUGINS)))
LIBPLUGCMXS = $(addsuffix .cmxs, $(addprefix lib/plugins/, $(PLUGINS)))

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
392 393

lib/plugins/%.cmxs: plugins/parser/%.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
394
	$(if $(QUIET),@echo 'Linking  $@' &&) \
395 396 397 398 399 400 401
	    $(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
402
	$(if $(QUIET),@echo 'Linking  $@' &&) \
403 404 405 406 407 408 409
	    $(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
410
	$(if $(QUIET),@echo 'Linking  $@' &&) \
411 412 413 414 415 416
	    $(OCAMLOPT) $(OFLAGS) -shared -o $@ $<

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

Andrei Paskevich's avatar
Andrei Paskevich committed
417
lib/plugins/tptp.cmxs: $(TPTPCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
418
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
419
	    $(OCAMLOPT) $(OFLAGS) -shared -o $@ $^
420

Andrei Paskevich's avatar
Andrei Paskevich committed
421
lib/plugins/tptp.cmo: $(TPTPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
422
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
423
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
424

Andrei Paskevich's avatar
Andrei Paskevich committed
425 426
# depend and clean targets

427
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
428 429 430
include $(PLUGDEP)
endif

431
depend: $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
432

Andrei Paskevich's avatar
Andrei Paskevich committed
433 434
CLEANDIRS += plugins $(addprefix plugins/, $(PLUGDIRS)) lib/plugins
GENERATED += $(PLUGGENERATED)
435 436 437

install_no_local::
	mkdir -p $(LIBDIR)/why3/plugins
438
	cp -f $(wildcard $(LIBPLUGCMO) $(LIBPLUGCMXS)) $(LIBDIR)/why3/plugins
439

440 441 442 443
###############
# Why3 commands
###############

Andrei Paskevich's avatar
Andrei Paskevich committed
444 445 446 447 448
TOOLSGENERATED = src/tools/why3wc.ml

TOOLS_BIN = why3config why3execute why3extract why3prove \
	    why3realize why3replay why3wc

Andrei Paskevich's avatar
Andrei Paskevich committed
449
TOOLS_FILES = main $(TOOLS_BIN)
450 451 452 453 454 455 456 457 458 459

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
460 461
$(TOOLSDEP): $(TOOLSGENERATED)

462 463 464
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

Andrei Paskevich's avatar
Andrei Paskevich committed
465
bin/why3.opt: lib/why3/why3.cmxa src/tools/main.cmx
466 467 468
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

Andrei Paskevich's avatar
Andrei Paskevich committed
469
bin/why3.byte: lib/why3/why3.cma src/tools/main.cmo
470 471
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
472

473 474 475 476 477 478 479 480
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) $^

Andrei Paskevich's avatar
Andrei Paskevich committed
481
bin/why3execute.opt: lib/why3/why3.cmxa src/tools/why3execute.cmx
482 483 484
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

Andrei Paskevich's avatar
Andrei Paskevich committed
485
bin/why3execute.byte: lib/why3/why3.cma src/tools/why3execute.cmo
486 487 488
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

Andrei Paskevich's avatar
Andrei Paskevich committed
489
bin/why3extract.opt: lib/why3/why3.cmxa src/tools/why3extract.cmx
490 491 492
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

Andrei Paskevich's avatar
Andrei Paskevich committed
493
bin/why3extract.byte: lib/why3/why3.cma src/tools/why3extract.cmo
494 495 496
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

Andrei Paskevich's avatar
Andrei Paskevich committed
497
bin/why3prove.opt: lib/why3/why3.cmxa src/tools/why3prove.cmx
498 499 500
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

Andrei Paskevich's avatar
Andrei Paskevich committed
501
bin/why3prove.byte: lib/why3/why3.cma src/tools/why3prove.cmo
502 503 504
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

Andrei Paskevich's avatar
Andrei Paskevich committed
505
bin/why3realize.opt: lib/why3/why3.cmxa src/tools/why3realize.cmx
506 507 508
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

Andrei Paskevich's avatar
Andrei Paskevich committed
509
bin/why3realize.byte: lib/why3/why3.cma src/tools/why3realize.cmo
510 511 512
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^

513
bin/why3replay.opt: lib/why3/why3.cmxa src/tools/why3replay.cmx
514 515 516
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

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

Andrei Paskevich's avatar
Andrei Paskevich committed
521 522 523 524 525 526 527 528
bin/why3wc.opt: src/tools/why3wc.cmx
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

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

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
529
clean_old_install::
530
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE)) $(BINDIR)/why3$(EXE)
531
	rm -f $(BINDIR)/why3bench$(EXE) $(BINDIR)/why3replayer$(EXE)
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
532

533
install_no_local::
534
	cp -f bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
535
	cp -f bin/why3config.@OCAMLBEST@  $(TOOLDIR)/why3config$(EXE)
536 537 538
	cp -f bin/why3execute.@OCAMLBEST@ $(TOOLDIR)/why3execute$(EXE)
	cp -f bin/why3extract.@OCAMLBEST@ $(TOOLDIR)/why3extract$(EXE)
	cp -f bin/why3prove.@OCAMLBEST@   $(TOOLDIR)/why3prove$(EXE)
539
	cp -f bin/why3realize.@OCAMLBEST@ $(TOOLDIR)/why3realize$(EXE)
540
	cp -f bin/why3replay.@OCAMLBEST@  $(TOOLDIR)/why3replay$(EXE)
Andrei Paskevich's avatar
Andrei Paskevich committed
541
	cp -f bin/why3wc.@OCAMLBEST@      $(TOOLDIR)/why3wc$(EXE)
542 543

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

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

548
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
549
include $(TOOLSDEP)
550 551
endif

552
depend: $(TOOLSDEP)
553

Andrei Paskevich's avatar
Andrei Paskevich committed
554 555 556
CLEANDIRS += src/tools
GENERATED += $(TOOLSGENERATED)

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
557
clean::
Andrei Paskevich's avatar
Andrei Paskevich committed
558
	rm -f bin/why3*
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
559

560 561 562
##############
# test targets
##############
563

564 565
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
566

567 568
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
569

570 571
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
572

573 574
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
575

576
%.type: %.mlw bin/why3ide.opt
577
	bin/why3.opt --type-only $*.mlw
578

579 580 581 582
##########
# gallery
##########

583
# we export exactly the programs that have a why3session.xml file
584 585 586

.PHONY: gallery

587 588
gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
Andrei Paskevich's avatar
Andrei Paskevich committed
589
	@for x in examples/*/why3session.xml ; do \
590 591
	  d=`dirname $$x`; \
	  f=`basename $$d`; \
592
	  why3 session html $$x; \
593 594
	  echo "exporting $$f"; \
	  mkdir -p $(GALLERYDIR)/$$f; \
595
	  cp examples/$$f.mlw examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
596
	  rm -f $(GALLERYDIR)/$$f/$$f.zip; \
Andrei Paskevich's avatar
Andrei Paskevich committed
597
	  cd examples/; \
598
	  zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f; \
599
	  cd ..; \
600
	done
601

602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617
.PHONY: gallery-subs

GALLERYSUBS=avl

gallery-subs::
	@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


618 619 620 621 622
%-gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
	x=$*/why3session.xml; \
	d=`dirname $$x`; \
	f=`basename $$d`; \
623
	why3 session html $$x; \
624 625
	echo "exporting $$f"; \
	mkdir -p $(GALLERYDIR)/$$f; \
626 627
	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; \
628
	cp examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
629 630
	rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	cd examples/; \
631
	zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f
632

MARCHE Claude's avatar
MARCHE Claude committed
633 634 635 636 637 638 639 640
########
# XML DTD validation
########

.PHONY: xml-validate

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

644 645 646 647 648
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
649 650 651 652
###############
# IDE
###############

653 654
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
655
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
656 657 658

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

Andrei Paskevich's avatar
Andrei Paskevich committed
659
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
660 661 662
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

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

666
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
667

668 669
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
670

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

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

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

682
src/ide/resetgc.o: src/ide/resetgc.c
683 684
	$(if $(QUIET),@echo 'Ocamlc   $<' &&) \
	    $(OCAMLC) -c -ccopt "-Wall -o $@" $<
685

MARCHE Claude's avatar
MARCHE Claude committed
686 687
# depend and clean targets

688
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
689 690
include $(IDEDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
691

Andrei Paskevich's avatar
Andrei Paskevich committed
692
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
693

Andrei Paskevich's avatar
Andrei Paskevich committed
694
CLEANDIRS += src/ide
MARCHE Claude's avatar
MARCHE Claude committed
695

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
696 697 698
clean_old_install::
	rm -f $(BINDIR)/why3ide$(EXE)

699
install_no_local::
700
	cp -f bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
701

702
install_local:: bin/why3ide
703

704
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
705

706 707 708 709
###############
# Session
###############

Andrei Paskevich's avatar
Andrei Paskevich committed
710 711 712
SESSION_FILES = why3session_lib why3session_copy why3session_info \
		why3session_latex why3session_html why3session_rm \
		why3session_output why3session_run why3session_csv \
713
		why3session_main
714 715 716

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

Andrei Paskevich's avatar
Andrei Paskevich committed
717
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
718 719 720
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
721
$(SESSIONDEP): DEPFLAGS += -I src/why3session
722 723 724 725 726 727 728
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

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

733
bin/why3session.byte: lib/why3/why3.cma $(SESSIONCMO)
734
	$(if $(QUIET),@echo 'Linking  $@' &&) \
735
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
736 737 738

# depend and clean targets

739
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
740 741
include $(SESSIONDEP)
endif
742

Andrei Paskevich's avatar
Andrei Paskevich committed
743
depend: $(SESSIONDEP)
744

Andrei Paskevich's avatar
Andrei Paskevich committed
745
CLEANDIRS += src/why3session
746

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
747 748 749
clean_old_install::
	rm -f $(BINDIR)/why3session$(EXE)

750
install_no_local::
751
	cp -f bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
752

753
install_local:: bin/why3session
754

MARCHE Claude's avatar
MARCHE Claude committed
755

756 757 758
##############
# Coq plugin
##############
759

Andrei Paskevich's avatar
Andrei Paskevich committed
760
ifeq (@enable_coq_tactic@,yes)
761

762
COQPGENERATED = src/coq-tactic/why3tac.ml
763

764
COQP_FILES = why3tac
765

766
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
767

768 769 770
COQPDEP = $(addsuffix .dep, $(COQPMODULES))
COQPCMO = $(addsuffix .cmo, $(COQPMODULES))
COQPCMX = $(addsuffix .cmx, $(COQPMODULES))
771

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

775
$(COQPDEP): DEPFLAGS += -I src/coq-tactic
776
$(COQPCMO) $(COQPCMX): INCLUDES += $(COQPINCLUDES)
Andrei Paskevich's avatar
Andrei Paskevich committed
777 778
$(COQPCMO) $(COQPCMX): BFLAGS += -rectypes
$(COQPCMX): OFLAGS += -rectypes
779

780
$(COQPDEP): $(COQPGENERATED)
781

782 783
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
784

785 786 787 788
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@)
789
lib/coq-tactic/why3tac.cma:  BFLAGS += $(addsuffix .cmo,  @MENHIRLIB@)
790

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

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

799
src/coq-tactic/why3tac.ml: src/coq-tactic/why3tac.ml4
800
	$(if $(QUIET),@echo 'Camlp    $<' &&) \
François Bobot's avatar
François Bobot committed
801
	    $(COQCAMLP) pr_dump.cmo @COQPPLIBS@ pa_macro.cmo -D@coq_compat_version@ -impl $^ -o $@
802

803
src/coq-tactic/.why3-vo-byte: lib/coq-tactic/Why3.v lib/coq/BuiltIn.vo lib/coq-tactic/why3tac.cma
Andrei Paskevich's avatar
Andrei Paskevich committed
804
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
805
	    WHY3CONFIG="" $(COQC) -byte -R lib/coq-tactic Why3 -R lib/coq Why3 $< && \
806
	    touch src/coq-tactic/.why3-vo-byte
807

808
src/coq-tactic/.why3-vo-opt: lib/coq-tactic/Why3.v lib/coq/BuiltIn.vo lib/coq-tactic/why3tac.cmxs
Andrei Paskevich's avatar
Andrei Paskevich committed
809
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
810
	    WHY3CONFIG="" $(COQC) -opt -R lib/coq-tactic Why3 -R lib/coq Why3 $< && \
811
	    touch src/coq-tactic/.why3-vo-opt
812

813
# depend and clean targets
Andrei Paskevich's avatar
Andrei Paskevich committed
814

815
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
816
include $(COQPDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
817
endif