Makefile.in 68.3 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@ $@

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
457
clean_old_install::
458
	rm -f $(BINDIR)/why3$(EXE) $(BINDIR)/why3contraption$(EXE)
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
459

460 461
install_no_local::
	cp -f bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
462
	cp -f bin/why3contraption.@OCAMLBEST@ $(BINDIR)/why3contraption$(EXE)
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
463

Guillaume Melquiond's avatar
Guillaume Melquiond committed
464
install_local:: bin/why3 bin/why3contraption
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
465

466
ifneq "$(MAKECMDGOALS)" "clean"
467 468 469
include src/tools/main.dep
include src/tools/why3contraption.dep
include src/tools/why3prove.dep
470 471
endif

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

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
474
clean::
475 476
	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
477
	rm -f bin/why3.byte bin/why3.opt bin/why3
478 479 480 481 482 483
	rm -f bin/why3contraption.byte bin/why3contraption.opt bin/why3contraption

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

484
TOOLS_BIN = why3execute why3extract why3prove why3realize why3replay
485
TOOLS_FILES = args $(TOOLS_BIN)
486 487 488 489 490 491 492 493 494 495

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

496 497 498 499 500 501 502 503 504 505 506 507 508
byte: $(TOOLS_BIN:%=bin/%.byte)
opt:  $(TOOLS_BIN:%=bin/%.opt)

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

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

bin/why3execute: bin/why3execute.@OCAMLBEST@
	ln -sf why3execute.@OCAMLBEST@ $@
509 510 511 512 513 514 515 516 517 518 519

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@ $@
520 521

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

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

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

532 533 534 535 536 537 538 539 540 541 542
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@ $@

543 544 545 546 547 548 549 550 551 552 553
bin/why3replay.opt: lib/why3/why3.cmxa src/tools/args.cmx src/tools/why3replay.cmx
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

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

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

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
554
clean_old_install::
555
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE))
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
556

557
install_no_local::
558 559 560
	cp -f bin/why3execute.@OCAMLBEST@ $(TOOLDIR)/why3execute$(EXE)
	cp -f bin/why3extract.@OCAMLBEST@ $(TOOLDIR)/why3extract$(EXE)
	cp -f bin/why3prove.@OCAMLBEST@   $(TOOLDIR)/why3prove$(EXE)
561
	cp -f bin/why3realize.@OCAMLBEST@ $(TOOLDIR)/why3realize$(EXE)
562
	cp -f bin/why3replay.@OCAMLBEST@ $(TOOLDIR)/why3replay$(EXE)
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
563

Guillaume Melquiond's avatar
Guillaume Melquiond committed
564
install_local:: $(addprefix bin/,$(TOOLS_BIN))
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
565

566
ifneq "$(MAKECMDGOALS)" "clean"
567
include $(TOOLSDEP)
568 569
endif

570
depend: $(TOOLSDEP)
571

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
572
clean::
573
	rm -f src/tools/args.cm[iox] src/tools/args.annot src/tools/args.o src/tools/args.dep
574
	rm -f src/tools/why3execute.cm[iox] src/tools/why3execute.annot src/tools/why3execute.o src/tools/why3execute.dep
575
	rm -f src/tools/why3extract.cm[iox] src/tools/why3extract.annot src/tools/why3extract.o src/tools/why3extract.dep
576
	rm -f src/tools/why3prove.cm[iox] src/tools/why3prove.annot src/tools/why3prove.o src/tools/why3prove.dep
577
	rm -f src/tools/why3realize.cm[iox] src/tools/why3realize.annot src/tools/why3realize.o src/tools/why3realize.dep
578
	rm -f src/tools/why3replay.cm[iox] src/tools/why3replay.annot src/tools/why3replay.o src/tools/why3replay.dep
579
	rm -f bin/why3execute.byte bin/why3execute.opt bin/why3execute
580
	rm -f bin/why3extract.byte bin/why3extract.opt bin/why3extract
581
	rm -f bin/why3prove.byte bin/why3prove.opt bin/why3prove
582
	rm -f bin/why3realize.byte bin/why3realize.opt bin/why3realize
583
	rm -f bin/why3replay.byte bin/why3replay.opt bin/why3replay
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
584

585 586 587
##############
# test targets
##############
588

589 590
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
591

592 593
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
594

595 596
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
597

598 599
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
600

601
%.type: %.mlw bin/why3ide.opt
602
	bin/why3.opt --type-only $*.mlw
603

604 605 606 607
##########
# gallery
##########

608
# we export exactly the programs that have a why3session.xml file
609 610 611

.PHONY: gallery

612 613
gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
Andrei Paskevich's avatar
Andrei Paskevich committed
614
	@for x in examples/*/why3session.xml ; do \
615 616
	  d=`dirname $$x`; \
	  f=`basename $$d`; \
617
	  why3session html $$x; \
618 619
	  echo "exporting $$f"; \
	  mkdir -p $(GALLERYDIR)/$$f; \
620
	  cp examples/$$f.mlw examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
621
	  rm -f $(GALLERYDIR)/$$f/$$f.zip; \
Andrei Paskevich's avatar
Andrei Paskevich committed
622
	  cd examples/; \
623
	  zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f; \
624
	  cd ..; \
625
	done
626

627 628 629 630 631 632 633 634
%-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; \
635 636
	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; \
637
	cp examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
638 639
	rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	cd examples/; \
640
	zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f
641

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

.PHONY: xml-validate

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

653 654 655 656 657
xml-validate-local:
	@for x in `find examples/ -name why3session.xml`; do \
	  xmllint --noout --dtdvalid share/why3session.dtd $$x 2>&1 | head -1; \
	done

658 659 660 661
########
# Config
########

662
CONFIG_FILES = why3config
663

664
CONFIGMODULES = $(addprefix src/why3config/, $(CONFIG_FILES))
665

Andrei Paskevich's avatar
Andrei Paskevich committed
666
CONFIGDEP = $(addsuffix .dep, $(CONFIGMODULES))
667 668 669 670 671
CONFIGCMO = $(addsuffix .cmo, $(CONFIGMODULES))
CONFIGCMX = $(addsuffix .cmx, $(CONFIGMODULES))

# build targets

672 673
byte: bin/why3config.byte
opt:  bin/why3config.opt
674

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

679
bin/why3config.byte: lib/why3/why3.cma $(CONFIGCMO)
680
	$(if $(QUIET),@echo 'Linking  $@' &&) \
681
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
682

683 684 685
bin/why3config: bin/why3config.@OCAMLBEST@
	ln -sf why3config.@OCAMLBEST@ $@

686 687
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
688 689 690
ifneq "$(MAKECMDGOALS)" "clean"
include $(CONFIGDEP)
endif
691

Andrei Paskevich's avatar
Andrei Paskevich committed
692
depend: $(CONFIGDEP)
693 694

clean::
695 696 697
	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
698
	rm -f bin/why3config.byte bin/why3config.opt bin/why3config
699

700 701
local_config: bin/why3config.@OCAMLBEST@
	WHY3LIB=$(PWD) WHY3DATA=$(PWD)/share bin/why3config.@OCAMLBEST@ \
702
		--detect --conf_file why3.conf
703

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
704 705 706
clean_old_install::
	rm -f $(BINDIR)/why3config$(EXE)

707
install_no_local::
708
	cp -f bin/why3config.@OCAMLBEST@ $(TOOLDIR)/why3config$(EXE)
709

710
install_local:: bin/why3config
711

MARCHE Claude's avatar
MARCHE Claude committed
712 713 714 715
###############
# IDE
###############

716 717
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
718
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
719 720 721

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

Andrei Paskevich's avatar
Andrei Paskevich committed
722
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
723 724 725
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

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

729
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
730

731 732
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
733

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

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

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

745 746 747
bin/why3ide: bin/why3ide.@OCAMLBEST@
	ln -sf why3ide.@OCAMLBEST@ $@

748
src/ide/resetgc.o: src/ide/resetgc.c
749
	$(OCAMLC) -c -ccopt "-Wall -o $@" $<
750

MARCHE Claude's avatar
MARCHE Claude committed
751 752
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
753 754 755
ifneq "$(MAKECMDGOALS)" "clean"
include $(IDEDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
756

Andrei Paskevich's avatar
Andrei Paskevich committed
757
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
758 759

clean::
760
	rm -f src/ide/xml.ml
MARCHE Claude's avatar
MARCHE Claude committed
761
	rm -f src/ide/*.cm[iox] src/ide/*.o
Andrei Paskevich's avatar
Andrei Paskevich committed
762
	rm -f src/ide/*.annot src/ide/*.dep src/ide/*~
763
	rm -f bin/why3ide.byte bin/why3ide.opt bin/why3ide
MARCHE Claude's avatar
MARCHE Claude committed
764

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
765 766 767
clean_old_install::
	rm -f $(BINDIR)/why3ide$(EXE)

768
install_no_local::
769
	cp -f bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
770

771
install_local:: bin/why3ide
772

773
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
774

775 776 777 778
###############
# Session
###############

779 780
SESSION_FILES = why3session_lib why3session_copy why3session_info	\
		why3session_latex why3session_html why3session_rm	\
781 782
		why3session_output why3session_run why3session_csv	\
		why3session
783 784 785

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

Andrei Paskevich's avatar
Andrei Paskevich committed
786
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
787 788 789
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
790
$(SESSIONDEP): DEPFLAGS += -I src/why3session
791 792 793 794 795 796 797
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

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

802
bin/why3session.byte: lib/why3/why3.cma $(SESSIONCMO)
803
	$(if $(QUIET),@echo 'Linking  $@' &&) \
804
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
805 806 807 808 809 810

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

# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
811 812 813
ifneq "$(MAKECMDGOALS)" "clean"
include $(SESSIONDEP)
endif
814

Andrei Paskevich's avatar
Andrei Paskevich committed
815
depend: $(SESSIONDEP)
816 817

clean::
Andrei Paskevich's avatar
Andrei Paskevich committed
818 819
	rm -f src/why3session/*.cm[iox] src/why3session/*.o
	rm -f src/why3session/*.annot src/why3session/*.dep src/why3session/*~
820 821
	rm -f bin/why3session.byte bin/why3session.opt bin/why3session

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
822 823 824
clean_old_install::
	rm -f $(BINDIR)/why3session$(EXE)

825
install_no_local::
826
	cp -f bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
827

828
install_local:: bin/why3session
829

MARCHE Claude's avatar
MARCHE Claude committed
830

831
###############
832
# Bench
833 834
###############

835 836
ifeq (@enable_bench@,yes)

837
BENCH_FILES = worker db bench benchrc benchdb why3bench
838

839
BENCHMODULES := $(addprefix src/why3bench/, $(BENCH_FILES))
840

Andrei Paskevich's avatar
Andrei Paskevich committed
841
BENCHDEP = $(addsuffix .dep, $(BENCHMODULES))
842 843 844
BENCHCMO = $(addsuffix .cmo, $(BENCHMODULES))
BENCHCMX = $(addsuffix .cmx, $(BENCHMODULES))

845 846
$(BENCHDEP): DEPFLAGS += -I src/why3bench
$(BENCHCMO) $(BENCHCMX): INCLUDES += -I src/why3bench -I @SQLITE3LIB@
847 848 849

# build targets