Makefile.in 59.8 KB
Newer Older
Andrei Paskevich's avatar
Andrei Paskevich committed
1 2 3
####################################################################
#                                                                  #
#  The Why3 Verification Platform   /   The Why3 Development Team  #
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
4
#  Copyright 2010-2014   --   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
CAMLP5O   = @CAMLP5O@
MARCHE Claude's avatar
MARCHE Claude committed
51
FRAMAC_LIBDIR = $(DESTDIR)@FRAMAC_LIBDIR@
52

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

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

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

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

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

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

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

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

88 89
# external libraries common to all binaries

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

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
95

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

99 100
TARGET_EMACS = share/emacs/why3.elc

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

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

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

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

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

121 122 123 124 125
install_local::
	ln -s ../drivers share/drivers
	ln -s ../modules share/modules
	ln -s ../theories share/theories

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

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

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

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

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

150
LIB_MLW = ity expr dexpr
151

152 153
LIB_PARSER = ptree glob parser typing lexer

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

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

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

173 174 175
LIB_SESSION = compress xml termcode session session_tools strategy \
              strategy_parser session_scheduler

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

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

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

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

197 198
$(LIBDEP): $(LIBGENERATED)

199 200 201
# Zarith

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

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

219
# build targets
220

221 222
byte: lib/why3/why3.cma
opt:  lib/why3/why3.cmxa
223

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

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

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

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

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

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

246
depend: $(LIBDEP)
247

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

252 253 254
###############
# installation
###############
255

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

261

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

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

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

MARCHE Claude's avatar
MARCHE Claude committed
310 311
install-all: install install-lib

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
312 313 314 315 316 317
##################
# Uninstallation
##################

uninstall: clean_old_install

318 319 320 321 322 323 324
##################
# Why3 emacs mode
##################

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

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


338
##################
339
# Why3 plugins
340 341
##################

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

346
PLUG_PARSER = genequlin dimacs
347
PLUG_PRINTER =
348
PLUG_TRANSFORM =
349
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
350

351
PLUGINS = genequlin dimacs tptp
352

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

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

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

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

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

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

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

383 384
$(PLUGDEP): $(PLUGGENERATED)

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

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
390 391

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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
423 424
# depend and clean targets

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

429
depend: $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
430

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

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

438 439 440 441
###############
# Why3 commands
###############

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

TOOLS_BIN = why3config why3execute why3extract why3prove \
	    why3realize why3replay why3wc

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

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
458 459
$(TOOLSDEP): $(TOOLSGENERATED)

460 461 462
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

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

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

471 472 473 474 475 476 477 478
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
479
bin/why3execute.opt: lib/why3/why3.cmxa src/tools/why3execute.cmx
480 481 482
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

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

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

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

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

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

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

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

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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
519 520 521 522 523 524 525 526
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
527
clean_old_install::
528
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE)) $(BINDIR)/why3$(EXE)
529
	rm -f $(BINDIR)/why3bench$(EXE) $(BINDIR)/why3replayer$(EXE)
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
530

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

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

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

546
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
547
include $(TOOLSDEP)
548 549
endif

550
depend: $(TOOLSDEP)
551

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

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

558 559 560
##############
# test targets
##############
561

562 563
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
564

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

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

571 572
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
573

574
%.type: %.mlw bin/why3ide.opt
575
	bin/why3.opt --type-only $*.mlw
576

577 578 579 580
##########
# gallery
##########

581
# we export exactly the programs that have a why3session.xml file
582 583 584

.PHONY: gallery

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

600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
.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


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

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

.PHONY: xml-validate

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

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

651 652
ifeq (@enable_ide@,yes)

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

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

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

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

664
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
665

666 667
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
668

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

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

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

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

MARCHE Claude's avatar
MARCHE Claude committed
684 685
# depend and clean targets

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

Andrei Paskevich's avatar
Andrei Paskevich committed
690
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
691

Andrei Paskevich's avatar
Andrei Paskevich committed
692
CLEANDIRS += src/ide
MARCHE Claude's avatar
MARCHE Claude committed
693

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

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

700
install_local:: bin/why3ide
701

702
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
703

704 705 706 707
###############
# Session
###############

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

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

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

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

# build targets

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

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

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

# depend and clean targets

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

Andrei Paskevich's avatar
Andrei Paskevich committed
741
depend: $(SESSIONDEP)
742

Andrei Paskevich's avatar
Andrei Paskevich committed
743
CLEANDIRS += src/why3session
744

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

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

751
install_local:: bin/why3session
752

MARCHE Claude's avatar
MARCHE Claude committed
753

754 755 756
##############
# Coq plugin
##############
757

Andrei Paskevich's avatar
Andrei Paskevich committed
758
ifeq (@enable_coq_tactic@,yes)
759

760
COQPGENERATED = src/coq-tactic/why3tac.ml
761

762
COQP_FILES = why3tac
763

764
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
765

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

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

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

778
$(COQPDEP): $(COQPGENERATED)
779

780 781
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
782

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

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

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

797
src/coq-tactic/why3tac.ml: src/coq-tactic/why3tac.ml4
Andrei Paskevich's avatar
Andrei Paskevich committed
798
	$(if $(QUIET),@echo 'Camlp5   $<' &&) \
799
	    $(CAMLP5O) pr_dump.cmo @COQPPLIBS@ pa_macro.cmo -D@coq_compat_version@ -impl $^ -o $@
800

801
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
802
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
803
	    WHY3CONFIG="" $(COQC) -byte -R lib/coq-tactic Why3 -R lib/coq Why3 $< && \
804
	    touch src/coq-tactic/.why3-vo-byte
805

806
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
807
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
808
	    WHY3CONFIG="" $(COQC) -opt -R lib/coq-tactic Why3 -R lib/coq Why3 $< && \
809
	    touch src/coq-tactic/.why3-vo-opt
810

811
# depend and clean targets
Andrei Paskevich's avatar
Andrei Paskevich committed
812

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

817
depend: $(COQPDEP)
818

Andrei Paskevich's avatar
Andrei Paskevich committed
819 820 821 822
CLEANDIRS += src/coq-tactic
CLEANLIBS +