Makefile.in 67.6 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
DEPFLAGS  = -slash -I lib/why3
54
ifeq (@OCAMLBEST@,opt)
Andrei Paskevich's avatar
Andrei Paskevich committed
55
DEPFLAGS += -native
56 57
endif

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

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

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

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

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

77 78
# external libraries common to all binaries

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

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
84

85 86
TARGET_EMACS = share/emacs/why3.elc

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

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

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

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

103 104 105
##############
# Why3 library
##############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
106

107
LIBGENERATED = src/util/config.ml \
108
	       src/util/rc.ml src/parser/lexer.ml \
109 110
	       src/parser/parser.mli src/parser/parser.ml \
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
111
	       src/driver/driver_lexer.ml src/session/xml.ml \
112
	       lib/ocaml/why3__BigInt_compat.ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
113

114
LIB_UTIL = config bigInt util opt lists strings extmap extset exthtbl weakhtbl \
115
	   hashcons stdlib exn_printer pp debug loc print_tree \
116
	   cmdline warning sysutil rc plugin bigInt number pqueue
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
117

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

121
LIB_PARSER = ptree glob parser typing lexer
122

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

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

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

François Bobot's avatar
François Bobot committed
140 141
LIB_SESSION = xml termcode session session_tools session_scheduler

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

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

155
LIBDIRS = util core parser driver transform printer session whyml
156
LIBINCLUDES = $(addprefix -I src/, $(LIBDIRS))
MARCHE Claude's avatar
MARCHE Claude committed
157

Andrei Paskevich's avatar
Andrei Paskevich committed
158
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
159 160
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
161

Andrei Paskevich's avatar
Andrei Paskevich committed
162
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
163
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
164
$(LIBCMX): OFLAGS += -for-pack Why3
165

166 167
$(LIBDEP): $(LIBGENERATED)

168 169 170 171
# Zarith

ifeq (@enable_zarith@,yes)

172
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_zarith.ml
173
	cp lib/ocaml/why3__BigInt_zarith.ml $@
174 175 176

else

177
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_num.ml
178
	cp lib/ocaml/why3__BigInt_num.ml $@
179 180 181

endif

182
clean::
183
	rm -f lib/ocaml/why3__BigInt_compat.ml
184

185
# build targets
186

187 188
byte: lib/why3/why3.cma
opt:  lib/why3/why3.cmxa
189

190
lib/why3/why3.cma: lib/why3/why3.cmo
Andrei Paskevich's avatar
Andrei Paskevich committed
191 192
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) -a $(BFLAGS) -o $@ $^
193

194
lib/why3/why3.cmxa: lib/why3/why3.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
195 196
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) -a $(OFLAGS) -o $@ $^
197

198
lib/why3/why3.cmo: $(LIBCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
199 200
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
201

202
lib/why3/why3.cmx: $(LIBCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
203 204
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -pack -o $@ $^
205

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

Andrei Paskevich's avatar
Andrei Paskevich committed
208 209 210
ifneq "$(MAKECMDGOALS)" "clean"
include $(LIBDEP)
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
211

212
depend: $(LIBDEP)
213

Andrei Paskevich's avatar
Andrei Paskevich committed
214
LIBSDIRS = src $(addprefix src/, $(LIBDIRS))
215 216
LIBCLEAN = $(addsuffix /*.cm[iox], $(LIBSDIRS)) \
	   $(addsuffix /*.annot, $(LIBSDIRS)) \
217 218
	   $(addsuffix /*.output, $(LIBSDIRS)) \
	   $(addsuffix /*.automaton, $(LIBSDIRS)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
219
	   $(addsuffix /*.dep, $(LIBSDIRS)) \
220 221 222 223 224
	   $(addsuffix /*.o, $(LIBSDIRS)) \
	   $(addsuffix /*~, $(LIBSDIRS))

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

227 228 229
###############
# installation
###############
230

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
231 232
clean_old_install::
	rm -rf $(LIBDIR)/why3
MARCHE Claude's avatar
MARCHE Claude committed
233
	rm -rf $(DATADIR)/why3
234
	rm -rf $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
235

236

237
ifeq ($(EMACS),no)
238
install_no_local:: clean_old_install
239 240 241
else
install_no_local:: clean_old_install $(TARGET_EMACS)
endif
242
	mkdir -p $(BINDIR)
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
243
	mkdir -p $(LIBDIR)/why3
244
	mkdir -p $(TOOLDIR)
245
	mkdir -p $(DATADIR)/why3
246
	mkdir -p $(DATADIR)/why3/images
247 248
	mkdir -p $(DATADIR)/why3/images/boomy
	mkdir -p $(DATADIR)/why3/images/fatcow
MARCHE Claude's avatar
MARCHE Claude committed
249
	mkdir -p $(DATADIR)/why3/emacs
250
	mkdir -p $(DATADIR)/why3/vim
251
	mkdir -p $(DATADIR)/why3/lang
MARCHE Claude's avatar
MARCHE Claude committed
252
	mkdir -p $(DATADIR)/why3/theories
253
	mkdir -p $(DATADIR)/why3/modules/mach
MARCHE Claude's avatar
MARCHE Claude committed
254
	mkdir -p $(DATADIR)/why3/drivers
255
	mkdir -p $(DATADIR)/emacs/site-lisp/
MARCHE Claude's avatar
MARCHE Claude committed
256
	cp -f theories/*.why $(DATADIR)/why3/theories
257
	cp -f modules/*.mlw $(DATADIR)/why3/modules
258
	cp -f modules/mach/*.mlw $(DATADIR)/why3/modules/mach
Andrei Paskevich's avatar
Andrei Paskevich committed
259
	cp -f drivers/*.drv drivers/*.gen $(DATADIR)/why3/drivers
260
	cp -f share/provers-detection-data.conf $(DATADIR)/why3/
261
	cp -f share/images/icons.rc $(DATADIR)/why3/images
262
	cp -f share/images/*.png $(DATADIR)/why3/images
263 264
	cp -f share/images/boomy/*.png $(DATADIR)/why3/images/boomy
	cp -f share/images/fatcow/*.png $(DATADIR)/why3/images/fatcow
265
	cp -f share/why3session.dtd $(DATADIR)/why3
266
	cp -rf share/javascript $(DATADIR)/why3/javascript
267 268
	cp -f share/vim/why3.vim $(DATADIR)/why3/vim/why3.vim
	cp -f share/lang/why3.lang $(DATADIR)/why3/lang/why3.lang
269

MARCHE Claude's avatar
MARCHE Claude committed
270
install_no_local_lib::
271
	mkdir -p $(OCAMLINSTALLLIB)/why3
Andrei Paskevich's avatar
Andrei Paskevich committed
272
	cp -f lib/why3/why3.cm* lib/why3/why3.[ao] \
273
		lib/why3/META $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
274

275 276
ifeq (@enable_local@,yes)
install install-lib:
277 278
	@echo "Why3 is configured in local installation mode."
	@echo "To install Why3, run ./configure --disable-local ; make ; make install"
279
else
MARCHE Claude's avatar
MARCHE Claude committed
280
install: clean_old_install install_no_local
MARCHE Claude's avatar
MARCHE Claude committed
281
install-lib: install_no_local_lib
282 283
endif

MARCHE Claude's avatar
MARCHE Claude committed
284 285
install-all: install install-lib

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
286 287 288 289 290 291
##################
# Uninstallation
##################

uninstall: clean_old_install

292 293 294 295 296 297 298
##################
# Why3 emacs mode
##################

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

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
299 300 301 302 303 304 305 306 307 308 309 310 311
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


312
##################
313
# Why3 plugins
314 315
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
316
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
317 318
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
		plugins/parser/dimacs.ml \
319

320
PLUG_PARSER = genequlin dimacs
321
PLUG_PRINTER =
322
PLUG_TRANSFORM =
323
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
324

325
PLUGINS = genequlin dimacs tptp
326

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

Andrei Paskevich's avatar
Andrei Paskevich committed
329 330
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
331

332 333 334 335 336 337 338 339 340 341
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

342 343
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
344
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
345
	      $(TPTPMODULES)
346

Andrei Paskevich's avatar
Andrei Paskevich committed
347
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
348 349 350
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
351
PLUGDIRS = parser printer transform tptp
352 353
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
354
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
355 356
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

357 358
$(PLUGDEP): $(PLUGGENERATED)

359 360 361 362 363
LIBPLUGCMO =  $(addsuffix .cmo,  $(addprefix lib/plugins/, $(PLUGINS)))
LIBPLUGCMXS = $(addsuffix .cmxs, $(addprefix lib/plugins/, $(PLUGINS)))

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
364 365

lib/plugins/%.cmxs: plugins/parser/%.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
366
	$(if $(QUIET),@echo 'Linking  $@' &&) \
367 368 369 370 371 372 373
	    $(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
374
	$(if $(QUIET),@echo 'Linking  $@' &&) \
375 376 377 378 379 380 381
	    $(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
382
	$(if $(QUIET),@echo 'Linking  $@' &&) \
383 384 385 386 387 388
	    $(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
389
lib/plugins/tptp.cmxs: $(TPTPCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
390
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
391
	    $(OCAMLOPT) $(OFLAGS) -shared -o $@ $^
392

Andrei Paskevich's avatar
Andrei Paskevich committed
393
lib/plugins/tptp.cmo: $(TPTPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
394
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
395
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
396 397 398 399 400 401

PLUGSDIRS = plugins $(addprefix plugins/, $(PLUGDIRS))
PLUGCLEAN = $(addsuffix /*.cm[iox], $(PLUGSDIRS)) \
	    $(addsuffix /*.annot, $(PLUGSDIRS)) \
	    $(addsuffix /*.output, $(PLUGSDIRS)) \
	    $(addsuffix /*.automaton, $(PLUGSDIRS)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
402
	    $(addsuffix /*.dep, $(PLUGSDIRS)) \
403 404 405
	    $(addsuffix /*.o, $(PLUGSDIRS)) \
	    $(addsuffix /*~, $(PLUGSDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
406 407 408 409 410 411
# depend and clean targets

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

412
depend: $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
413

414 415 416 417 418 419
clean::
	rm -f $(PLUGCLEAN) $(PLUGGENERATED)
	rm -f lib/plugins/*

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

422 423 424
######
# Why3
######
425

426 427
src/tools/main.cmo: lib/why3/why3.cma
src/tools/main.cmx: lib/why3/why3.cmxa
428

429 430
src/tools/why3contraption.cmo: lib/why3/why3.cma
src/tools/why3contraption.cmx: lib/why3/why3.cmxa
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
431

432 433
byte: bin/why3.byte bin/why3contraption.byte
opt:  bin/why3.opt  bin/why3contraption.opt
434 435

bin/why3.opt: lib/why3/why3.cmxa src/tools/main.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
436
	$(if $(QUIET),@echo 'Linking  $@' &&) \
437
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
438

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

443 444
bin/why3: bin/why3.@OCAMLBEST@
	ln -sf why3.@OCAMLBEST@ $@
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
445

446 447 448 449 450 451 452 453 454 455 456
bin/why3contraption.opt: lib/why3/why3.cmxa src/tools/why3contraption.cmx
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

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

bin/why3contraption: bin/why3contraption.@OCAMLBEST@
	ln -sf why3contraption.@OCAMLBEST@ $@

457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
clean_old_install::
	rm -f $(BINDIR)/why3$(EXE) $(BINDIR)/why3contraption$(EXE)

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

install_local: bin/why3 bin/why3contraption bin/why3prove

ifneq "$(MAKECMDGOALS)" "clean"
include src/tools/main.dep
include src/tools/why3contraption.dep
include src/tools/why3prove.dep
endif

depend: src/tools/main.dep src/tools/why3contraption.dep

clean::
	rm -f src/tools/main.cm[iox] src/tools/main.annot src/tools/main.o src/tools/main.dep
	rm -f src/tools/why3contraption.cm[iox] src/tools/why3contraption.annot src/tools/why3contraption.o src/tools/why3contraption.dep
	rm -f bin/why3.byte bin/why3.opt bin/why3
	rm -f bin/why3contraption.byte bin/why3contraption.opt bin/why3contraption

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

484
TOOLS_FILES = args why3extract why3prove why3realize
485 486 487 488 489 490 491 492 493 494

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

495 496 497 498 499 500 501 502 503 504 505 506 507
byte: bin/why3extract.byte bin/why3prove.byte bin/why3realize.byte
opt:  bin/why3extract.opt  bin/why3prove.opt  bin/why3realize.opt

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

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

bin/why3extract: bin/why3extract.@OCAMLBEST@
	ln -sf why3extract.@OCAMLBEST@ $@
508 509

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

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

bin/why3prove: bin/why3prove.@OCAMLBEST@
	ln -sf why3prove.@OCAMLBEST@ $@

520 521 522 523 524 525 526 527 528 529 530
bin/why3realize.opt: lib/why3/why3.cmxa src/tools/args.cmx src/tools/why3realize.cmx
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

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

bin/why3realize: bin/why3realize.@OCAMLBEST@
	ln -sf why3realize.@OCAMLBEST@ $@

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
531
clean_old_install::
532
	rm -f  $(TOOLDIR)/why3extract$(EXE) $(TOOLDIR)/why3prove$(EXE) $(TOOLDIR)/why3realize$(EXE)
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
533

534
install_no_local::
535
	cp -f bin/why3prove.@OCAMLBEST@ $(TOOLDIR)/why3prove$(EXE)
536
	cp -f bin/why3realize.@OCAMLBEST@ $(TOOLDIR)/why3realize$(EXE)
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
537

538
install_local: bin/why3extract bin/why3prove bin/why3realize
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
539

540
ifneq "$(MAKECMDGOALS)" "clean"
541
include $(TOOLSDEP)
542 543
endif

544
depend: $(TOOLSDEP)
545

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
546
clean::
547
	rm -f src/tools/args.cm[iox] src/tools/args.annot src/tools/args.o src/tools/args.dep
548
	rm -f src/tools/why3extract.cm[iox] src/tools/why3extract.annot src/tools/why3extract.o src/tools/why3extract.dep
549
	rm -f src/tools/why3prove.cm[iox] src/tools/why3prove.annot src/tools/why3prove.o src/tools/why3prove.dep
550
	rm -f src/tools/why3realize.cm[iox] src/tools/why3realize.annot src/tools/why3realize.o src/tools/why3realize.dep
551
	rm -f bin/why3extract.byte bin/why3extract.opt bin/why3extract
552
	rm -f bin/why3prove.byte bin/why3prove.opt bin/why3prove
553
	rm -f bin/why3realize.byte bin/why3realize.opt bin/why3realize
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
554

555 556 557
##############
# test targets
##############
558

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

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

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

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

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

574 575 576 577
##########
# gallery
##########

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

.PHONY: gallery

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

597 598 599 600 601 602 603 604
%-gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
	x=$*/why3session.xml; \
	d=`dirname $$x`; \
	f=`basename $$d`; \
	why3session html $$x; \
	echo "exporting $$f"; \
	mkdir -p $(GALLERYDIR)/$$f; \
605 606
	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; \
607
	cp examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
608 609
	rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	cd examples/; \
610
	zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f
611

MARCHE Claude's avatar
MARCHE Claude committed
612 613 614 615 616 617 618 619
########
# XML DTD validation
########

.PHONY: xml-validate

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

623 624 625 626 627
xml-validate-local:
	@for x in `find examples/ -name why3session.xml`; do \
	  xmllint --noout --dtdvalid share/why3session.dtd $$x 2>&1 | head -1; \
	done

628 629 630 631
########
# Config
########

632
CONFIG_FILES = why3config
633

634
CONFIGMODULES = $(addprefix src/why3config/, $(CONFIG_FILES))
635

Andrei Paskevich's avatar
Andrei Paskevich committed
636
CONFIGDEP = $(addsuffix .dep, $(CONFIGMODULES))
637 638 639 640 641
CONFIGCMO = $(addsuffix .cmo, $(CONFIGMODULES))
CONFIGCMX = $(addsuffix .cmx, $(CONFIGMODULES))

# build targets

642 643
byte: bin/why3config.byte
opt:  bin/why3config.opt
644

645
bin/why3config.opt: lib/why3/why3.cmxa $(CONFIGCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
646
	$(if $(QUIET),@echo 'Linking  $@' &&) \
647
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
648

649
bin/why3config.byte: lib/why3/why3.cma $(CONFIGCMO)
650
	$(if $(QUIET),@echo 'Linking  $@' &&) \
651
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
652

653 654 655
bin/why3config: bin/why3config.@OCAMLBEST@
	ln -sf why3config.@OCAMLBEST@ $@

656 657
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
658 659 660
ifneq "$(MAKECMDGOALS)" "clean"
include $(CONFIGDEP)
endif
661

Andrei Paskevich's avatar
Andrei Paskevich committed
662
depend: $(CONFIGDEP)
663 664

clean::
665 666 667
	rm -f src/why3config/*.cm[iox] src/why3config/*.o
	rm -f src/why3config/*.annot src/why3config/*.dep src/why3config/*~
	rm -f src/why3config/*.output src/why3config/*.automaton
668
	rm -f bin/why3config.byte bin/why3config.opt bin/why3config
669

670 671
local_config: bin/why3config.@OCAMLBEST@
	WHY3LIB=$(PWD) WHY3DATA=$(PWD)/share bin/why3config.@OCAMLBEST@ \
672
		--detect --conf_file why3.conf
673

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
674 675 676
clean_old_install::
	rm -f $(BINDIR)/why3config$(EXE)

677
install_no_local::
678
	cp -f bin/why3config.@OCAMLBEST@ $(TOOLDIR)/why3config$(EXE)
679

680
install_local: bin/why3config
681

MARCHE Claude's avatar
MARCHE Claude committed
682 683 684 685
###############
# IDE
###############

686 687
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
688
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
689 690 691

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

Andrei Paskevich's avatar
Andrei Paskevich committed
692
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
693 694 695
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

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

699
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
700

701 702
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
703

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

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

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

715 716 717
bin/why3ide: bin/why3ide.@OCAMLBEST@
	ln -sf why3ide.@OCAMLBEST@ $@

718
src/ide/resetgc.o: src/ide/resetgc.c
719
	$(OCAMLC) -c -ccopt "-Wall -o $@" $<
720

MARCHE Claude's avatar
MARCHE Claude committed
721 722
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
723 724 725
ifneq "$(MAKECMDGOALS)" "clean"
include $(IDEDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
726

Andrei Paskevich's avatar
Andrei Paskevich committed
727
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
728 729

clean::
730
	rm -f src/ide/xml.ml
MARCHE Claude's avatar
MARCHE Claude committed
731
	rm -f src/ide/*.cm[iox] src/ide/*.o
Andrei Paskevich's avatar
Andrei Paskevich committed
732
	rm -f src/ide/*.annot src/ide/*.dep src/ide/*~
733
	rm -f bin/why3ide.byte bin/why3ide.opt bin/why3ide
MARCHE Claude's avatar
MARCHE Claude committed
734

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
735 736 737
clean_old_install::
	rm -f $(BINDIR)/why3ide$(EXE)

738
install_no_local::
739
	cp -f bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
740 741

install_local: bin/why3ide
742

743
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
744

745

MARCHE Claude's avatar
MARCHE Claude committed
746 747 748 749
###############
# Replayer
###############

François Bobot's avatar
François Bobot committed
750
REPLAYER_FILES = replay
MARCHE Claude's avatar
MARCHE Claude committed
751

752
REPLAYERMODULES = $(addprefix src/why3replayer/, $(REPLAYER_FILES))
MARCHE Claude's avatar
MARCHE Claude committed
753

Andrei Paskevich's avatar
Andrei Paskevich committed
754
REPLAYERDEP = $(addsuffix .dep, $(REPLAYERMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
755 756 757
REPLAYERCMO = $(addsuffix .cmo, $(REPLAYERMODULES))
REPLAYERCMX = $(addsuffix .cmx, $(REPLAYERMODULES))

758 759
$(REPLAYERDEP): DEPFLAGS += -I src/why3replayer
$(REPLAYERCMO) $(REPLAYERCMX): INCLUDES += -I src/why3replayer
MARCHE Claude's avatar
MARCHE Claude committed
760 761 762 763 764 765

# build targets

byte: bin/why3replayer.byte
opt:  bin/why3replayer.opt

766
bin/why3replayer.opt: lib/why3/why3.cmxa $(REPLAYERCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
767
	$(if $(QUIET),@echo 'Linking  $@' &&) \
768
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
MARCHE Claude's avatar
MARCHE Claude committed
769

770
bin/why3replayer.byte: lib/why3/why3.cma $(REPLAYERCMO)
MARCHE Claude's avatar
MARCHE Claude committed
771
	$(if $(QUIET),@echo 'Linking  $@' &&) \
772
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
MARCHE Claude's avatar
MARCHE Claude committed
773 774 775 776 777 778

bin/why3replayer: bin/why3replayer.@OCAMLBEST@
	ln -sf why3replayer.@OCAMLBEST@ $@

# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
779 780 781
ifneq "$(MAKECMDGOALS)" "clean"
include $(REPLAYERDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
782

Andrei Paskevich's avatar
Andrei Paskevich committed
783
depend: $(REPLAYERDEP)
MARCHE Claude's avatar
MARCHE Claude committed
784 785

clean::
786 787
	rm -f src/why3replayer/*.cm[iox] src/why3replayer/*.o
	rm -f src/why3replayer/*.annot src/why3replayer/*.dep src/why3replayer/*~
MARCHE Claude's avatar
MARCHE Claude committed
788 789
	rm -f bin/why3replayer.byte bin/why3replayer.opt bin/why3replayer

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
790 791 792
clean_old_install::
	rm -f $(BINDIR)/why3replayer$(EXE)

MARCHE Claude's avatar
MARCHE Claude committed
793
install_no_local::
794
	cp -f bin/why3replayer.@OCAMLBEST@ $(TOOLDIR)/why3replayer$(EXE)
MARCHE Claude's avatar
MARCHE Claude committed
795 796 797

install_local: bin/why3replayer

798 799 800 801 802

###############
# Session
###############

803 804
SESSION_FILES = why3session_lib why3session_copy why3session_info	\
		why3session_latex why3session_html why3session_rm	\
805 806
		why3session_output why3session_run why3session_csv	\
		why3session
807 808 809

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

Andrei Paskevich's avatar
Andrei Paskevich committed
810
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
811 812 813
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
814
$(SESSIONDEP): DEPFLAGS += -I src/why3session
815 816 817 818 819 820 821
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

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

826
bin/why3session.byte: lib/why3/why3.cma $(SESSIONCMO)
827
	$(if $(QUIET),@echo 'Linking  $@' &&) \
828
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
829 830 831 832 833 834

bin/why3session: bin/why3session.@OCAMLBEST@
	ln -sf why3session.@OCAMLBEST@ $@

# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
835 836 837
ifneq "$(MAKECMDGOALS)" "clean"
include $(SESSIONDEP)
endif
838

Andrei Paskevich's avatar
Andrei Paskevich committed
839
depend: $(SESSIONDEP)
840 841

clean::
Andrei Paskevich's avatar
Andrei Paskevich committed
842 843
	rm -f src/why3session/*.cm[iox] src/why3session/*.o
	rm -f src/why3session/*.annot src/why3session/*.dep src/why3session/*~
844 845
	rm -f bin/why3session.byte bin/why3session.opt bin/why3session

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
846 847 848
clean_old_install::
	rm -f $(BINDIR)/why3session$(EXE)

849
install_no_local::
850
	cp -f bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
851 852 853

install_local: bin/why3session

MARCHE Claude's avatar
MARCHE Claude committed
854

855
###############
856
# Bench
857 858
###############

859 860
ifeq (@enable_bench@,yes)

861
BENCH_FILES = worker db bench benchrc benchdb why3bench
862

863
BENCHMODULES := $(addprefix src/why3bench/, $(BENCH_FILES))
864

Andrei Paskevich's avatar
Andrei Paskevich committed
865
BENCHDEP = $(addsuffix .dep, $(BENCHMODULES))