Makefile.in 62.3 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 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 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 76
WARNINGS = Aer-41-44-45@5
OFLAGS = -w $(WARNINGS) -dtypes -g -I lib/why3 $(INCLUDES)
BFLAGS = -w $(WARNINGS) -dtypes -g -I lib/why3 $(INCLUDES)
77 78 79

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

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

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

90 91
# external libraries common to all binaries

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

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
97

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

101 102
TARGET_EMACS = share/emacs/why3.elc

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

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

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

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

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

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

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

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

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

148
LIB_CORE = ident ty term pattern decl theory \
149
	   task pretty dterm env trans printer model_parser
150

151
LIB_DRIVER = call_provers driver_ast driver_parser driver_lexer driver \
152
	     whyconf autodetection \
153
             parse_smtv2_model_parser parse_smtv2_model_lexer parse_smtv2_model
154

155
LIB_MLW = ity expr dexpr pdecl pmodule
156

157 158
LIB_PARSER = ptree glob parser typing lexer

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

173
LIB_PRINTER = alt_ergo why3printer smtv1 smtv2 coq pvs isabelle \
174
	      simplify gappa cvc3 yices mathematica
175

176
LIB_WHYML = mlw_ty mlw_expr mlw_decl mlw_pretty mlw_wp mlw_module \
177
	    mlw_dexpr mlw_typing mlw_driver mlw_exec mlw_ocaml \
178
	    mlw_main mlw_interp
179

180 181 182
LIB_SESSION = compress xml termcode session session_tools strategy \
              strategy_parser session_scheduler

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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
196
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
197 198
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
199

Andrei Paskevich's avatar
Andrei Paskevich committed
200
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
201
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
202
$(LIBCMX): OFLAGS += -for-pack Why3
203

204 205
$(LIBDEP): $(LIBGENERATED)

206 207 208
# Zarith

ifeq (@enable_zarith@,yes)
209
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_zarith.ml
210
	cp lib/ocaml/why3__BigInt_zarith.ml $@
211
else
212
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_num.ml
213
	cp lib/ocaml/why3__BigInt_num.ml $@
214 215
endif

216 217 218 219 220 221 222 223 224 225
# 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

226 227 228 229 230
# hide deprecated warnings for strings

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

231
# build targets
232

233 234
byte: lib/why3/why3.cma
opt:  lib/why3/why3.cmxa
235

236
lib/why3/why3.cma: lib/why3/why3.cmo
Andrei Paskevich's avatar
Andrei Paskevich committed
237 238
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) -a $(BFLAGS) -o $@ $^
239

240
lib/why3/why3.cmxa: lib/why3/why3.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
241 242
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) -a $(OFLAGS) -o $@ $^
243

244
lib/why3/why3.cmo: $(LIBCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
245 246
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
247

248
lib/why3/why3.cmx: $(LIBCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
249 250
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -pack -o $@ $^
251

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

254
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
255
include $(LIBDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
256
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
257

258
depend: $(LIBDEP)
259

Andrei Paskevich's avatar
Andrei Paskevich committed
260 261 262
CLEANDIRS += src $(addprefix src/, $(LIBDIRS))
CLEANLIBS += lib/why3/why3session lib/why3/why3
GENERATED += $(LIBGENERATED)
263

264 265 266
###############
# installation
###############
267

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
268 269
clean_old_install::
	rm -rf $(LIBDIR)/why3
MARCHE Claude's avatar
MARCHE Claude committed
270
	rm -rf $(DATADIR)/why3
271
	rm -rf $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
272

273

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

MARCHE Claude's avatar
MARCHE Claude committed
308
install_no_local_lib::
309
	mkdir -p $(OCAMLINSTALLLIB)/why3
310
	cp -f $(wildcard $(addprefix lib/why3/why3., $(INSTALLED_LIB_EXTS))) \
311
		lib/why3/META $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
312

313 314
ifeq (@enable_local@,yes)
install install-lib:
315 316
	@echo "Why3 is configured in local installation mode."
	@echo "To install Why3, run ./configure --disable-local ; make ; make install"
317
else
MARCHE Claude's avatar
MARCHE Claude committed
318
install: clean_old_install install_no_local
MARCHE Claude's avatar
MARCHE Claude committed
319
install-lib: install_no_local_lib
320 321
endif

MARCHE Claude's avatar
MARCHE Claude committed
322 323
install-all: install install-lib

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
324 325 326 327 328 329
##################
# Uninstallation
##################

uninstall: clean_old_install

330 331 332 333 334 335 336
##################
# Why3 emacs mode
##################

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

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
337 338 339 340 341 342 343 344 345 346 347 348 349
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


350
##################
351
# Why3 plugins
352 353
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
354
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
355 356
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
		plugins/parser/dimacs.ml \
357

358
PLUG_PARSER = genequlin dimacs
359
PLUG_PRINTER =
360
PLUG_TRANSFORM =
361
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
362

363
PLUGINS = genequlin dimacs tptp
364

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

Andrei Paskevich's avatar
Andrei Paskevich committed
367 368
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
369

370 371 372 373 374 375 376 377 378 379
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

380 381
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
382
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
383
	      $(TPTPMODULES)
384

Andrei Paskevich's avatar
Andrei Paskevich committed
385
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
386 387 388
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
389
PLUGDIRS = parser printer transform tptp
390 391
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
392
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
393 394
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

395 396
$(PLUGDEP): $(PLUGGENERATED)

397 398 399 400 401
LIBPLUGCMO =  $(addsuffix .cmo,  $(addprefix lib/plugins/, $(PLUGINS)))
LIBPLUGCMXS = $(addsuffix .cmxs, $(addprefix lib/plugins/, $(PLUGINS)))

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
402 403

lib/plugins/%.cmxs: plugins/parser/%.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
404
	$(if $(QUIET),@echo 'Linking  $@' &&) \
405 406 407 408 409 410 411
	    $(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
412
	$(if $(QUIET),@echo 'Linking  $@' &&) \
413 414 415 416 417 418 419
	    $(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
420
	$(if $(QUIET),@echo 'Linking  $@' &&) \
421 422 423 424 425 426
	    $(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
427
lib/plugins/tptp.cmxs: $(TPTPCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
428
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
429
	    $(OCAMLOPT) $(OFLAGS) -shared -o $@ $^
430

Andrei Paskevich's avatar
Andrei Paskevich committed
431
lib/plugins/tptp.cmo: $(TPTPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
432
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
433
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
434

Andrei Paskevich's avatar
Andrei Paskevich committed
435 436
# depend and clean targets

437
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
438 439 440
include $(PLUGDEP)
endif

441
depend: $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
442

Andrei Paskevich's avatar
Andrei Paskevich committed
443 444
CLEANDIRS += plugins $(addprefix plugins/, $(PLUGDIRS)) lib/plugins
GENERATED += $(PLUGGENERATED)
445 446 447

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

450 451 452 453
###############
# Why3 commands
###############

Andrei Paskevich's avatar
Andrei Paskevich committed
454 455 456 457 458
TOOLSGENERATED = src/tools/why3wc.ml

TOOLS_BIN = why3config why3execute why3extract why3prove \
	    why3realize why3replay why3wc

Andrei Paskevich's avatar
Andrei Paskevich committed
459
TOOLS_FILES = main $(TOOLS_BIN)
460 461 462 463 464 465 466 467 468 469

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
470 471
$(TOOLSDEP): $(TOOLSGENERATED)

472 473 474
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

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

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

483 484 485 486 487 488 489 490
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
491
bin/why3execute.opt: lib/why3/why3.cmxa src/tools/why3execute.cmx
492 493 494
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

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

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

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

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

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

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

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

523
bin/why3replay.opt: lib/why3/why3.cmxa src/tools/why3replay.cmx
524 525 526
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

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

Andrei Paskevich's avatar
Andrei Paskevich committed
531 532 533 534 535 536 537 538
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
539
clean_old_install::
540
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE)) $(BINDIR)/why3$(EXE)
541
	rm -f $(BINDIR)/why3bench$(EXE) $(BINDIR)/why3replayer$(EXE)
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
542

543
install_no_local::
544
	cp -f bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
545
	cp -f bin/why3config.@OCAMLBEST@  $(TOOLDIR)/why3config$(EXE)
546 547 548
	cp -f bin/why3execute.@OCAMLBEST@ $(TOOLDIR)/why3execute$(EXE)
	cp -f bin/why3extract.@OCAMLBEST@ $(TOOLDIR)/why3extract$(EXE)
	cp -f bin/why3prove.@OCAMLBEST@   $(TOOLDIR)/why3prove$(EXE)
549
	cp -f bin/why3realize.@OCAMLBEST@ $(TOOLDIR)/why3realize$(EXE)
550
	cp -f bin/why3replay.@OCAMLBEST@  $(TOOLDIR)/why3replay$(EXE)
Andrei Paskevich's avatar
Andrei Paskevich committed
551
	cp -f bin/why3wc.@OCAMLBEST@      $(TOOLDIR)/why3wc$(EXE)
552 553

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

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

558
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
559
include $(TOOLSDEP)
560 561
endif

562
depend: $(TOOLSDEP)
563

Andrei Paskevich's avatar
Andrei Paskevich committed
564 565 566
CLEANDIRS += src/tools
GENERATED += $(TOOLSGENERATED)

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
567
clean::
Andrei Paskevich's avatar
Andrei Paskevich committed
568
	rm -f bin/why3*
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
569

570 571 572
##############
# test targets
##############
573

574 575
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
576

577 578
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
579

580 581
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
582

583 584
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
585

586
%.type: %.mlw bin/why3ide.opt
587
	bin/why3.opt --type-only $*.mlw
588

589 590 591 592
##########
# gallery
##########

593
# we export exactly the programs that have a why3session.xml file
594 595 596

.PHONY: gallery

597 598
gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
Andrei Paskevich's avatar
Andrei Paskevich committed
599
	@for x in examples/*/why3session.xml ; do \
600 601
	  d=`dirname $$x`; \
	  f=`basename $$d`; \
602
	  why3 session html $$x; \
603 604
	  echo "exporting $$f"; \
	  mkdir -p $(GALLERYDIR)/$$f; \
605
	  cp examples/$$f.mlw examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
606
	  rm -f $(GALLERYDIR)/$$f/$$f.zip; \
Andrei Paskevich's avatar
Andrei Paskevich committed
607
	  cd examples/; \
608
	  zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f; \
609
	  cd ..; \
610
	done
611

612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
.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


628 629 630 631 632
%-gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
	x=$*/why3session.xml; \
	d=`dirname $$x`; \
	f=`basename $$d`; \
633
	why3 session html $$x; \
634 635
	echo "exporting $$f"; \
	mkdir -p $(GALLERYDIR)/$$f; \
636 637
	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; \
638
	cp examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
639 640
	rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	cd examples/; \
641
	zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f
642

MARCHE Claude's avatar
MARCHE Claude committed
643 644 645 646 647 648 649 650
########
# XML DTD validation
########

.PHONY: xml-validate

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

654 655 656 657 658
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
659 660 661 662
###############
# IDE
###############

663 664
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
665
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
666 667 668

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

Andrei Paskevich's avatar
Andrei Paskevich committed
669
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
670 671 672
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

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

676
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
677

678 679
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
680

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

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

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

692
src/ide/resetgc.o: src/ide/resetgc.c
693 694
	$(if $(QUIET),@echo 'Ocamlc   $<' &&) \
	    $(OCAMLC) -c -ccopt "-Wall -o $@" $<
695

MARCHE Claude's avatar
MARCHE Claude committed
696 697
# depend and clean targets

698
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
699 700
include $(IDEDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
701

Andrei Paskevich's avatar
Andrei Paskevich committed
702
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
703

Andrei Paskevich's avatar
Andrei Paskevich committed
704
CLEANDIRS += src/ide
MARCHE Claude's avatar
MARCHE Claude committed
705

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
706 707 708
clean_old_install::
	rm -f $(BINDIR)/why3ide$(EXE)

709
install_no_local::
710
	cp -f bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
711

712
install_local:: bin/why3ide
713

714
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
715

716 717 718 719
###############
# Session
###############

Andrei Paskevich's avatar
Andrei Paskevich committed
720 721 722
SESSION_FILES = why3session_lib why3session_copy why3session_info \
		why3session_latex why3session_html why3session_rm \
		why3session_output why3session_run why3session_csv \
723
		why3session_main
724 725 726

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

Andrei Paskevich's avatar
Andrei Paskevich committed
727
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
728 729 730
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
731
$(SESSIONDEP): DEPFLAGS += -I src/why3session
732 733 734 735 736 737 738
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

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

743
bin/why3session.byte: lib/why3/why3.cma $(SESSIONCMO)
744
	$(if $(QUIET),@echo 'Linking  $@' &&) \
745
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
746 747 748

# depend and clean targets

749
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
750 751
include $(SESSIONDEP)
endif
752

Andrei Paskevich's avatar
Andrei Paskevich committed
753
depend: $(SESSIONDEP)
754

Andrei Paskevich's avatar
Andrei Paskevich committed
755
CLEANDIRS += src/why3session
756

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
757 758 759
clean_old_install::
	rm -f $(BINDIR)/why3session$(EXE)

760
install_no_local::
761
	cp -f bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
762

763
install_local:: bin/why3session
764

MARCHE Claude's avatar
MARCHE Claude committed
765

766 767 768
##############
# Coq plugin
##############
769

Andrei Paskevich's avatar
Andrei Paskevich committed
770
ifeq (@enable_coq_tactic@,yes)
771

772
COQPGENERATED = src/coq-tactic/why3tac.ml
773

774
COQP_FILES = why3tac
775

776
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
777

778 779 780
COQPDEP = $(addsuffix .dep, $(COQPMODULES))
COQPCMO = $(addsuffix .cmo, $(COQPMODULES))
COQPCMX = $(addsuffix .cmx, $(COQPMODULES))
781

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

785
$(COQPDEP): DEPFLAGS += -I src/coq-tactic
786
$(COQPCMO) $(COQPCMX): INCLUDES += $(COQPINCLUDES)
Andrei Paskevich's avatar
Andrei Paskevich committed
787 788
$(COQPCMO) $(COQPCMX): BFLAGS += -rectypes
$(COQPCMX): OFLAGS += -rectypes
789

790
$(COQPDEP): $(COQPGENERATED)
791

792 793
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
794

795 796 797 798
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@)
799
lib/coq-tactic/why3tac.cma:  BFLAGS += $(addsuffix .cmo,  @MENHIRLIB@)
800

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

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

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

813
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
814
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
815
	    WHY3CONFIG="" $(COQC) -byte -R lib/coq-tactic Why3 -R lib/coq Why3 $< && \
816
	    touch src/coq-tactic/.why3-vo-byte
817

818
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
819
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
820
	    WHY3CONFIG="" $(COQC) -opt -R lib/coq-tactic Why3 -R lib/coq Why3 $< && \