Makefile.in 61.1 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 = @ZIPINCLUDE@
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 @ZIPLIB@
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/util/lexlib.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 \
112
	       src/session/compress.ml src/session/xml.ml \
113
	       src/session/strategy_parser.ml \
114
	       lib/ocaml/why3__BigInt_compat.ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
115

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

121 122
LIB_CORE = ident ty term pattern decl theory \
	   task pretty dterm env trans printer
123

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

127
LIB_MLW = ity
128

129 130
LIB_PARSER = ptree glob parser typing lexer

131
LIB_TRANSFORM = simplify_formula inlining split_goal induction \
132
		eliminate_definition eliminate_algebraic \
133
		eliminate_inductive eliminate_let eliminate_if \
134 135 136 137
		libencoding discriminate encoding encoding_select \
		encoding_guards_full encoding_tags_full \
		encoding_guards encoding_tags encoding_twin \
		encoding_sort simplify_array filter_trigger \
138
		introduction abstraction close_epsilon lift_epsilon \
139
		eliminate_epsilon \
MARCHE Claude's avatar
MARCHE Claude committed
140
		eval_match instantiate_predicate smoke_detector \
141
		reduction_engine compute
142

143
LIB_PRINTER = alt_ergo why3printer smtv1 smtv2 coq pvs isabelle \
144
	      simplify gappa cvc3 yices mathematica
145

146
LIB_WHYML = mlw_ty mlw_expr mlw_decl mlw_pretty mlw_wp mlw_module \
147
	    mlw_dexpr mlw_typing mlw_driver mlw_ocaml \
148
	    mlw_main mlw_interp
149

150 151 152
LIB_SESSION = compress xml termcode session session_tools strategy \
              strategy_parser session_scheduler

153
LIBMODULES =  $(addprefix src/util/, $(LIB_UTIL)) \
154 155
	      $(addprefix src/core/, $(LIB_CORE)) \
	      $(addprefix src/driver/, $(LIB_DRIVER)) \
156
	      $(addprefix src/mlw/, $(LIB_MLW)) \
157
	      $(addprefix src/parser/, $(LIB_PARSER)) \
158
	      $(addprefix src/transform/, $(LIB_TRANSFORM)) \
François Bobot's avatar
François Bobot committed
159
	      $(addprefix src/printer/, $(LIB_PRINTER)) \
160 161
	      $(addprefix src/whyml/, $(LIB_WHYML)) \
	      $(addprefix src/session/, $(LIB_SESSION))
162

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

Andrei Paskevich's avatar
Andrei Paskevich committed
166
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
167 168
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
169

Andrei Paskevich's avatar
Andrei Paskevich committed
170
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
171
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
172
$(LIBCMX): OFLAGS += -for-pack Why3
173

174 175
$(LIBDEP): $(LIBGENERATED)

176 177 178
# Zarith

ifeq (@enable_zarith@,yes)
179
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_zarith.ml
180
	cp lib/ocaml/why3__BigInt_zarith.ml $@
181
else
182
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_num.ml
183
	cp lib/ocaml/why3__BigInt_num.ml $@
184 185
endif

186
clean::
187
	rm -f lib/ocaml/why3__BigInt_compat.ml
188

189 190 191 192 193 194 195 196 197 198 199 200 201
# 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

clean::
	rm -f src/session/compress.ml

202
# build targets
203

204 205
byte: lib/why3/why3.cma
opt:  lib/why3/why3.cmxa
206

207
lib/why3/why3.cma: lib/why3/why3.cmo
Andrei Paskevich's avatar
Andrei Paskevich committed
208 209
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) -a $(BFLAGS) -o $@ $^
210

211
lib/why3/why3.cmxa: lib/why3/why3.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
212 213
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) -a $(OFLAGS) -o $@ $^
214

215
lib/why3/why3.cmo: $(LIBCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
216 217
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
218

219
lib/why3/why3.cmx: $(LIBCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
220 221
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -pack -o $@ $^
222

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

225
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
226
include $(LIBDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
227
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
228

229
depend: $(LIBDEP)
230

Andrei Paskevich's avatar
Andrei Paskevich committed
231
LIBSDIRS = src $(addprefix src/, $(LIBDIRS))
232 233
LIBCLEAN = $(addsuffix /*.cm[iox], $(LIBSDIRS)) \
	   $(addsuffix /*.annot, $(LIBSDIRS)) \
234 235
	   $(addsuffix /*.output, $(LIBSDIRS)) \
	   $(addsuffix /*.automaton, $(LIBSDIRS)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
236
	   $(addsuffix /*.dep, $(LIBSDIRS)) \
237 238 239 240 241
	   $(addsuffix /*.o, $(LIBSDIRS)) \
	   $(addsuffix /*~, $(LIBSDIRS))

clean::
	rm -f $(LIBCLEAN) $(LIBGENERATED)
242
	rm -f lib/why3/why3session.* lib/why3/why3.cm* lib/why3/why3.[ao]
243

244 245 246
###############
# installation
###############
247

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
248 249
clean_old_install::
	rm -rf $(LIBDIR)/why3
MARCHE Claude's avatar
MARCHE Claude committed
250
	rm -rf $(DATADIR)/why3
251
	rm -rf $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
252

253

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

MARCHE Claude's avatar
MARCHE Claude committed
286
install_no_local_lib::
287
	mkdir -p $(OCAMLINSTALLLIB)/why3
Andrei Paskevich's avatar
Andrei Paskevich committed
288
	cp -f lib/why3/why3.cm* lib/why3/why3.[ao] \
289
		lib/why3/META $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
290

291 292
ifeq (@enable_local@,yes)
install install-lib:
293 294
	@echo "Why3 is configured in local installation mode."
	@echo "To install Why3, run ./configure --disable-local ; make ; make install"
295
else
MARCHE Claude's avatar
MARCHE Claude committed
296
install: clean_old_install install_no_local
MARCHE Claude's avatar
MARCHE Claude committed
297
install-lib: install_no_local_lib
298 299
endif

MARCHE Claude's avatar
MARCHE Claude committed
300 301
install-all: install install-lib

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
302 303 304 305 306 307
##################
# Uninstallation
##################

uninstall: clean_old_install

308 309 310 311 312 313 314
##################
# Why3 emacs mode
##################

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

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
315 316 317 318 319 320 321 322 323 324 325 326 327
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


328
##################
329
# Why3 plugins
330 331
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
332
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
333 334
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
		plugins/parser/dimacs.ml \
335

336
PLUG_PARSER = genequlin dimacs
337
PLUG_PRINTER =
338
PLUG_TRANSFORM =
339
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
340

341
PLUGINS = genequlin dimacs tptp
342

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

Andrei Paskevich's avatar
Andrei Paskevich committed
345 346
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
347

348 349 350 351 352 353 354 355 356 357
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

358 359
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
360
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
361
	      $(TPTPMODULES)
362

Andrei Paskevich's avatar
Andrei Paskevich committed
363
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
364 365 366
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
367
PLUGDIRS = parser printer transform tptp
368 369
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
370
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
371 372
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

373 374
$(PLUGDEP): $(PLUGGENERATED)

375 376 377 378 379
LIBPLUGCMO =  $(addsuffix .cmo,  $(addprefix lib/plugins/, $(PLUGINS)))
LIBPLUGCMXS = $(addsuffix .cmxs, $(addprefix lib/plugins/, $(PLUGINS)))

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
380 381

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

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

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
418
	    $(addsuffix /*.dep, $(PLUGSDIRS)) \
419 420 421
	    $(addsuffix /*.o, $(PLUGSDIRS)) \
	    $(addsuffix /*~, $(PLUGSDIRS))

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

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

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

430 431 432 433 434 435
clean::
	rm -f $(PLUGCLEAN) $(PLUGGENERATED)
	rm -f lib/plugins/*

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

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

442
TOOLS_BIN = why3config why3execute why3extract why3prove why3realize why3replay
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

454 455 456
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

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

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

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

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

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

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

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

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

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

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

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

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

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
513
clean_old_install::
514
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE)) $(BINDIR)/why3$(EXE)
515
	rm -f $(BINDIR)/why3bench$(EXE) $(BINDIR)/why3replayer$(EXE)
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
516

517
install_no_local::
518
	cp -f bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
519
	cp -f bin/why3config.@OCAMLBEST@  $(TOOLDIR)/why3config$(EXE)
520 521 522
	cp -f bin/why3execute.@OCAMLBEST@ $(TOOLDIR)/why3execute$(EXE)
	cp -f bin/why3extract.@OCAMLBEST@ $(TOOLDIR)/why3extract$(EXE)
	cp -f bin/why3prove.@OCAMLBEST@   $(TOOLDIR)/why3prove$(EXE)
523
	cp -f bin/why3realize.@OCAMLBEST@ $(TOOLDIR)/why3realize$(EXE)
524 525 526
	cp -f bin/why3replay.@OCAMLBEST@  $(TOOLDIR)/why3replay$(EXE)

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

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

531
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
532
include $(TOOLSDEP)
533 534
endif

535
depend: $(TOOLSDEP)
536

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
537
clean::
538
	rm -f src/tools/main.cm[iox] src/tools/main.annot src/tools/main.o src/tools/main.dep
539
	rm -f src/tools/why3config.cm[iox] src/tools/why3config.annot src/tools/why3config.o src/tools/why3config.dep
540
	rm -f src/tools/why3execute.cm[iox] src/tools/why3execute.annot src/tools/why3execute.o src/tools/why3execute.dep
541
	rm -f src/tools/why3extract.cm[iox] src/tools/why3extract.annot src/tools/why3extract.o src/tools/why3extract.dep
542
	rm -f src/tools/why3prove.cm[iox] src/tools/why3prove.annot src/tools/why3prove.o src/tools/why3prove.dep
543
	rm -f src/tools/why3realize.cm[iox] src/tools/why3realize.annot src/tools/why3realize.o src/tools/why3realize.dep
544
	rm -f src/tools/why3replay.cm[iox] src/tools/why3replay.annot src/tools/why3replay.o src/tools/why3replay.dep
545 546 547
	rm -f $(addprefix bin/,$(TOOLS_BIN))
	rm -f $(TOOLS_BIN:%=bin/%.byte) $(TOOLS_BIN:%=bin/%.opt)
	rm -f bin/why3.byte bin/why3.opt bin/why3
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
548

549 550 551
##############
# test targets
##############
552

553 554
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
555

556 557
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
558

559 560
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
561

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

565
%.type: %.mlw bin/why3ide.opt
566
	bin/why3.opt --type-only $*.mlw
567

568 569 570 571
##########
# gallery
##########

572
# we export exactly the programs that have a why3session.xml file
573 574 575

.PHONY: gallery

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

591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
.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


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

MARCHE Claude's avatar
MARCHE Claude committed
622 623 624 625 626 627 628 629
########
# XML DTD validation
########

.PHONY: xml-validate

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

633 634 635 636 637
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
638 639 640 641
###############
# IDE
###############

642 643
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
644
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
645 646 647

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

Andrei Paskevich's avatar
Andrei Paskevich committed
648
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
649 650 651
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

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

655
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
656

657 658
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
659

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

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

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

671
src/ide/resetgc.o: src/ide/resetgc.c
672 673
	$(if $(QUIET),@echo 'Ocamlc   $<' &&) \
	    $(OCAMLC) -c -ccopt "-Wall -o $@" $<
674

MARCHE Claude's avatar
MARCHE Claude committed
675 676
# depend and clean targets

677
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
678 679
include $(IDEDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
680

Andrei Paskevich's avatar
Andrei Paskevich committed
681
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
682 683

clean::
684
	rm -f src/ide/xml.ml
MARCHE Claude's avatar
MARCHE Claude committed
685
	rm -f src/ide/*.cm[iox] src/ide/*.o
Andrei Paskevich's avatar
Andrei Paskevich committed
686
	rm -f src/ide/*.annot src/ide/*.dep src/ide/*~
687
	rm -f bin/why3ide.byte bin/why3ide.opt bin/why3ide
MARCHE Claude's avatar
MARCHE Claude committed
688

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

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

695
install_local:: bin/why3ide
696

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

699 700 701 702
###############
# Session
###############

703 704
SESSION_FILES = why3session_lib why3session_copy why3session_info	\
		why3session_latex why3session_html why3session_rm	\
705
		why3session_output why3session_run why3session_csv	\
706
		why3session_main
707 708 709

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

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

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

# build targets

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

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

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

# depend and clean targets

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

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

clean::
Andrei Paskevich's avatar
Andrei Paskevich committed
739 740
	rm -f src/why3session/*.cm[iox] src/why3session/*.o
	rm -f src/why3session/*.annot src/why3session/*.dep src/why3session/*~
741 742
	rm -f bin/why3session.byte bin/why3session.opt bin/why3session

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

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

749
install_local:: bin/why3session
750

MARCHE Claude's avatar
MARCHE Claude committed
751

752 753 754
##############
# Coq plugin
##############
755

Andrei Paskevich's avatar
Andrei Paskevich committed
756
ifeq (@enable_coq_tactic@,yes)
757

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

Claude Marche's avatar
Claude Marche committed
760
COQP_FILES = coqCompat why3tac g_why3tac
761

762
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
763

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

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

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

776
$(COQPDEP): $(COQPGENERATED)
777

778 779
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
780

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

784
lib/coq-tactic/why3tac.cmxs: lib/why3/why3.cmxa $(COQPCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
785
	$(if $(QUIET),@echo 'Linking  $@' &&) \
786
	    $(OCAMLOPT) $(OFLAGS) -o $@ -shared $(addsuffix .cmxa, @ZIPLIB@) $^
787

788
lib/coq-tactic/why3tac.cma: lib/why3/why3.cma $(COQPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
789
	$(if $(QUIET),@echo 'Linking  $@' &&) \
790
	    $(OCAMLC) -a $(BFLAGS) -o $@ $(addsuffix .cma, @ZIPLIB@) $^
791

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

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

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

806
# depend and clean targets
Andrei Paskevich's avatar
Andrei Paskevich committed
807

808
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
809
include $(COQPDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
810
endif
811

812