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
##############
# Why3 library
##############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
124

125
LIBGENERATED = src/util/config.ml \
126
	       src/util/rc.ml src/util/lexlib.ml src/parser/lexer.ml \
127 128
	       src/parser/parser.mli src/parser/parser.ml \
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
129
	       src/driver/driver_lexer.ml \
130
	       src/session/compress.ml src/session/xml.ml \
131
	       src/session/strategy_parser.ml \
132
	       lib/ocaml/why3__BigInt_compat.ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
133

134 135
LIB_UTIL = config bigInt util opt lists strings \
	   extmap extset exthtbl weakhtbl \
136
	   hashcons stdlib exn_printer pp debug loc lexlib print_tree \
137
	   cmdline warning sysutil rc plugin bigInt number pqueue
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
138

139 140
LIB_CORE = ident ty term pattern decl theory \
	   task pretty dterm env trans printer
141

142
LIB_DRIVER = call_provers driver_ast driver_parser driver_lexer driver \
143
	     whyconf autodetection
144

145
LIB_MLW = ity expr dexpr
146

147 148
LIB_PARSER = ptree glob parser typing lexer

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

162
LIB_PRINTER = alt_ergo why3printer smtv1 smtv2 coq pvs isabelle \
163
	      simplify gappa cvc3 yices mathematica
164

165
LIB_WHYML = mlw_ty mlw_expr mlw_decl mlw_pretty mlw_wp mlw_module \
166
	    mlw_dexpr mlw_typing mlw_driver mlw_exec mlw_ocaml \
167
	    mlw_main mlw_interp
168

169 170 171
LIB_SESSION = compress xml termcode session session_tools strategy \
              strategy_parser session_scheduler

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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
185
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
186 187
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
188

Andrei Paskevich's avatar
Andrei Paskevich committed
189
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
190
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
191
$(LIBCMX): OFLAGS += -for-pack Why3
192

193 194
$(LIBDEP): $(LIBGENERATED)

195 196 197
# Zarith

ifeq (@enable_zarith@,yes)
198
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_zarith.ml
199
	cp lib/ocaml/why3__BigInt_zarith.ml $@
200
else
201
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_num.ml
202
	cp lib/ocaml/why3__BigInt_num.ml $@
203 204
endif

205 206 207 208 209 210 211 212 213 214
# 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

215
# build targets
216

217 218
byte: lib/why3/why3.cma
opt:  lib/why3/why3.cmxa
219

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

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

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

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

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

238
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
239
include $(LIBDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
240
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
241

242
depend: $(LIBDEP)
243

Andrei Paskevich's avatar
Andrei Paskevich committed
244 245 246
CLEANDIRS += src $(addprefix src/, $(LIBDIRS))
CLEANLIBS += lib/why3/why3session lib/why3/why3
GENERATED += $(LIBGENERATED)
247

248 249 250
###############
# installation
###############
251

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
252 253
clean_old_install::
	rm -rf $(LIBDIR)/why3
MARCHE Claude's avatar
MARCHE Claude committed
254
	rm -rf $(DATADIR)/why3
255
	rm -rf $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
256

257

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

MARCHE Claude's avatar
MARCHE Claude committed
292
install_no_local_lib::
293
	mkdir -p $(OCAMLINSTALLLIB)/why3
294
	cp -f $(wildcard $(addprefix lib/why3/why3., $(INSTALLED_LIB_EXTS))) \
295
		lib/why3/META $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
296

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

MARCHE Claude's avatar
MARCHE Claude committed
306 307
install-all: install install-lib

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
308 309 310 311 312 313
##################
# Uninstallation
##################

uninstall: clean_old_install

314 315 316 317 318 319 320
##################
# Why3 emacs mode
##################

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

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
321 322 323 324 325 326 327 328 329 330 331 332 333
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


334
##################
335
# Why3 plugins
336 337
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
338
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
339 340
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
		plugins/parser/dimacs.ml \
341

342
PLUG_PARSER = genequlin dimacs
343
PLUG_PRINTER =
344
PLUG_TRANSFORM =
345
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
346

347
PLUGINS = genequlin dimacs tptp
348

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

Andrei Paskevich's avatar
Andrei Paskevich committed
351 352
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
353

354 355 356 357 358 359 360 361 362 363
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

364 365
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
366
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
367
	      $(TPTPMODULES)
368

Andrei Paskevich's avatar
Andrei Paskevich committed
369
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
370 371 372
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
373
PLUGDIRS = parser printer transform tptp
374 375
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
376
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
377 378
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

379 380
$(PLUGDEP): $(PLUGGENERATED)

381 382 383 384 385
LIBPLUGCMO =  $(addsuffix .cmo,  $(addprefix lib/plugins/, $(PLUGINS)))
LIBPLUGCMXS = $(addsuffix .cmxs, $(addprefix lib/plugins/, $(PLUGINS)))

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
386 387

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

Andrei Paskevich's avatar
Andrei Paskevich committed
415
lib/plugins/tptp.cmo: $(TPTPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
416
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
417
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
418

Andrei Paskevich's avatar
Andrei Paskevich committed
419 420
# depend and clean targets

421
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
422 423 424
include $(PLUGDEP)
endif

425
depend: $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
426

Andrei Paskevich's avatar
Andrei Paskevich committed
427 428
CLEANDIRS += plugins $(addprefix plugins/, $(PLUGDIRS)) lib/plugins
GENERATED += $(PLUGGENERATED)
429 430 431

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

434 435 436 437
###############
# Why3 commands
###############

Andrei Paskevich's avatar
Andrei Paskevich committed
438 439 440 441 442
TOOLSGENERATED = src/tools/why3wc.ml

TOOLS_BIN = why3config why3execute why3extract why3prove \
	    why3realize why3replay why3wc

Andrei Paskevich's avatar
Andrei Paskevich committed
443
TOOLS_FILES = main $(TOOLS_BIN)
444 445 446 447 448 449 450 451 452 453

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
454 455
$(TOOLSDEP): $(TOOLSGENERATED)

456 457 458
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

542
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
543
include $(TOOLSDEP)
544 545
endif

546
depend: $(TOOLSDEP)
547

Andrei Paskevich's avatar
Andrei Paskevich committed
548 549 550
CLEANDIRS += src/tools
GENERATED += $(TOOLSGENERATED)

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
551
clean::
Andrei Paskevich's avatar
Andrei Paskevich committed
552
	rm -f bin/why3*
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
553

554 555 556
##############
# test targets
##############
557

558 559
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
560

561 562
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
563

564 565
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
566

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

570
%.type: %.mlw bin/why3ide.opt
571
	bin/why3.opt --type-only $*.mlw
572

573 574 575 576
##########
# gallery
##########

577
# we export exactly the programs that have a why3session.xml file
578 579 580

.PHONY: gallery

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

596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611
.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


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

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

.PHONY: xml-validate

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

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

647 648
ifeq (@enable_ide@,yes)

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

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

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

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

660
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
661

662 663
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
664

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

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

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

676
src/ide/resetgc.o: src/ide/resetgc.c
677 678
	$(if $(QUIET),@echo 'Ocamlc   $<' &&) \
	    $(OCAMLC) -c -ccopt "-Wall -o $@" $<
679

MARCHE Claude's avatar
MARCHE Claude committed
680 681
# depend and clean targets

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

Andrei Paskevich's avatar
Andrei Paskevich committed
686
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
687

Andrei Paskevich's avatar
Andrei Paskevich committed
688
CLEANDIRS += src/ide
MARCHE Claude's avatar
MARCHE Claude committed
689

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

693
install_no_local::
694
	cp -f bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
695

696
install_local:: bin/why3ide
697

698
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
699

700 701 702 703
###############
# Session
###############

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

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

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

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

# build targets

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

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

727
bin/why3session.byte: lib/why3/why3.cma $(SESSIONCMO)
728
	$(if $(QUIET),@echo 'Linking  $@' &&) \
729
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
730 731 732

# depend and clean targets

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

Andrei Paskevich's avatar
Andrei Paskevich committed
737
depend: $(SESSIONDEP)
738

Andrei Paskevich's avatar
Andrei Paskevich committed
739
CLEANDIRS += src/why3session
740

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

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

747
install_local:: bin/why3session
748

MARCHE Claude's avatar
MARCHE Claude committed
749

750 751 752
##############
# Coq plugin
##############
753

Andrei Paskevich's avatar
Andrei Paskevich committed
754
ifeq (@enable_coq_tactic@,yes)
755

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

Claude Marche's avatar
Claude Marche committed
758
COQP_FILES = coqCompat why3tac g_why3tac
759

760
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
761

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

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

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

774
$(COQPDEP): $(COQPGENERATED)
775

776 777
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
778

Andrei Paskevich's avatar
Andrei Paskevich committed
779 780
src/coq-tactic/coqCompat.ml: src/coq-tactic/coqCompat@coq_compat_version@.ml
	cp -f $< $@
781

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

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

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

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

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

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

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

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

816
depend: $(COQPDEP)
817

Andrei Paskevich's avatar
Andrei Paskevich committed
818 819 820 821
CLEANDIRS += src/coq-tactic
CLEANLIBS += lib/coq-tactic/why3tac
GENERATED += $(COQPGENERATED)

822
clean::