Makefile.in 58.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 = @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

Andrei Paskevich's avatar
Andrei Paskevich committed
85 86 87
INSTALLED_LIB_EXTS = a cma cmx cmi cmxa cmxs
COMPILED_LIB_EXTS = $(INSTALLED_LIB_EXTS) o cmo annot dep output

88 89
TARGET_EMACS = share/emacs/why3.elc

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
90 91 92
###############
# main target
###############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
93

94 95 96 97
all: @OCAMLBEST@
plugins: plugins.@OCAMLBEST@
opt: plugins.opt
byte: plugins.byte
Francois Bobot's avatar
Francois Bobot committed
98

99 100 101 102 103
ifeq (@enable_local@,yes)
all: install_local
endif

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

Andrei Paskevich's avatar
Andrei Paskevich committed
106 107 108 109
CLEANDIRS =
CLEANLIBS =
GENERATED =

110 111 112
##############
# Why3 library
##############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
113

114
LIBGENERATED = src/util/config.ml \
115
	       src/util/rc.ml src/util/lexlib.ml src/parser/lexer.ml \
116 117
	       src/parser/parser.mli src/parser/parser.ml \
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
118
	       src/driver/driver_lexer.ml \
119
	       src/session/compress.ml src/session/xml.ml \
120
	       src/session/strategy_parser.ml \
121
	       lib/ocaml/why3__BigInt_compat.ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
122

123 124
LIB_UTIL = config bigInt util opt lists strings \
	   extmap extset exthtbl weakhtbl \
125
	   hashcons stdlib exn_printer pp debug loc lexlib print_tree \
126
	   cmdline warning sysutil rc plugin bigInt number pqueue
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
127

128 129
LIB_CORE = ident ty term pattern decl theory \
	   task pretty dterm env trans printer
130

131
LIB_DRIVER = call_provers driver_ast driver_parser driver_lexer driver \
132
	     whyconf autodetection
133

134
LIB_MLW = ity
135

136 137
LIB_PARSER = ptree glob parser typing lexer

138
LIB_TRANSFORM = simplify_formula inlining split_goal induction \
139
		eliminate_definition eliminate_algebraic \
140
		eliminate_inductive eliminate_let eliminate_if \
141 142 143 144
		libencoding discriminate encoding encoding_select \
		encoding_guards_full encoding_tags_full \
		encoding_guards encoding_tags encoding_twin \
		encoding_sort simplify_array filter_trigger \
145
		introduction abstraction close_epsilon lift_epsilon \
146
		eliminate_epsilon \
MARCHE Claude's avatar
MARCHE Claude committed
147
		eval_match instantiate_predicate smoke_detector \
148
		reduction_engine compute
149

150
LIB_PRINTER = alt_ergo why3printer smtv1 smtv2 coq pvs isabelle \
151
	      simplify gappa cvc3 yices mathematica
152

153
LIB_WHYML = mlw_ty mlw_expr mlw_decl mlw_pretty mlw_wp mlw_module \
154
	    mlw_dexpr mlw_typing mlw_driver mlw_ocaml \
155
	    mlw_main mlw_interp
156

157 158 159
LIB_SESSION = compress xml termcode session session_tools strategy \
              strategy_parser session_scheduler

160
LIBMODULES =  $(addprefix src/util/, $(LIB_UTIL)) \
161 162
	      $(addprefix src/core/, $(LIB_CORE)) \
	      $(addprefix src/driver/, $(LIB_DRIVER)) \
163
	      $(addprefix src/mlw/, $(LIB_MLW)) \
164
	      $(addprefix src/parser/, $(LIB_PARSER)) \
165
	      $(addprefix src/transform/, $(LIB_TRANSFORM)) \
François Bobot's avatar
François Bobot committed
166
	      $(addprefix src/printer/, $(LIB_PRINTER)) \
167 168
	      $(addprefix src/whyml/, $(LIB_WHYML)) \
	      $(addprefix src/session/, $(LIB_SESSION))
169

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

Andrei Paskevich's avatar
Andrei Paskevich committed
173
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
174 175
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
176

Andrei Paskevich's avatar
Andrei Paskevich committed
177
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
178
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
179
$(LIBCMX): OFLAGS += -for-pack Why3
180

181 182
$(LIBDEP): $(LIBGENERATED)

183 184 185
# Zarith

ifeq (@enable_zarith@,yes)
186
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_zarith.ml
187
	cp lib/ocaml/why3__BigInt_zarith.ml $@
188
else
189
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_num.ml
190
	cp lib/ocaml/why3__BigInt_num.ml $@
191 192
endif

193 194 195 196 197 198 199 200 201 202
# 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

203
# build targets
204

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

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

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

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

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

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

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

230
depend: $(LIBDEP)
231

Andrei Paskevich's avatar
Andrei Paskevich committed
232 233 234
CLEANDIRS += src $(addprefix src/, $(LIBDIRS))
CLEANLIBS += lib/why3/why3session lib/why3/why3
GENERATED += $(LIBGENERATED)
235

236 237 238
###############
# installation
###############
239

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
240 241
clean_old_install::
	rm -rf $(LIBDIR)/why3
MARCHE Claude's avatar
MARCHE Claude committed
242
	rm -rf $(DATADIR)/why3
243
	rm -rf $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
244

245

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

MARCHE Claude's avatar
MARCHE Claude committed
278
install_no_local_lib::
279
	mkdir -p $(OCAMLINSTALLLIB)/why3
Andrei Paskevich's avatar
Andrei Paskevich committed
280
	cp -f $(addprefix lib/why3/why3., $(INSTALLED_LIB_EXTS)) \
281
		lib/why3/META $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
282

283 284
ifeq (@enable_local@,yes)
install install-lib:
285 286
	@echo "Why3 is configured in local installation mode."
	@echo "To install Why3, run ./configure --disable-local ; make ; make install"
287
else
MARCHE Claude's avatar
MARCHE Claude committed
288
install: clean_old_install install_no_local
MARCHE Claude's avatar
MARCHE Claude committed
289
install-lib: install_no_local_lib
290 291
endif

MARCHE Claude's avatar
MARCHE Claude committed
292 293
install-all: install install-lib

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
294 295 296 297 298 299
##################
# Uninstallation
##################

uninstall: clean_old_install

300 301 302 303 304 305 306
##################
# Why3 emacs mode
##################

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

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
307 308 309 310 311 312 313 314 315 316 317 318 319
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


320
##################
321
# Why3 plugins
322 323
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
324
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
325 326
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
		plugins/parser/dimacs.ml \
327

328
PLUG_PARSER = genequlin dimacs
329
PLUG_PRINTER =
330
PLUG_TRANSFORM =
331
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
332

333
PLUGINS = genequlin dimacs tptp
334

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

Andrei Paskevich's avatar
Andrei Paskevich committed
337 338
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
339

340 341 342 343 344 345 346 347 348 349
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

350 351
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
352
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
353
	      $(TPTPMODULES)
354

Andrei Paskevich's avatar
Andrei Paskevich committed
355
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
356 357 358
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
359
PLUGDIRS = parser printer transform tptp
360 361
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
362
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
363 364
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

365 366
$(PLUGDEP): $(PLUGGENERATED)

367 368 369 370 371
LIBPLUGCMO =  $(addsuffix .cmo,  $(addprefix lib/plugins/, $(PLUGINS)))
LIBPLUGCMXS = $(addsuffix .cmxs, $(addprefix lib/plugins/, $(PLUGINS)))

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
372 373

lib/plugins/%.cmxs: plugins/parser/%.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/parser/%.cmo
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $<

lib/plugins/%.cmxs: plugins/printer/%.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/printer/%.cmo
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $<

lib/plugins/%.cmxs: plugins/transform/%.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
390
	$(if $(QUIET),@echo 'Linking  $@' &&) \
391 392 393 394 395 396
	    $(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
397
lib/plugins/tptp.cmxs: $(TPTPCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
398
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
399
	    $(OCAMLOPT) $(OFLAGS) -shared -o $@ $^
400

Andrei Paskevich's avatar
Andrei Paskevich committed
401
lib/plugins/tptp.cmo: $(TPTPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
402
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
403
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
404

Andrei Paskevich's avatar
Andrei Paskevich committed
405 406
# depend and clean targets

407
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
408 409 410
include $(PLUGDEP)
endif

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

Andrei Paskevich's avatar
Andrei Paskevich committed
413 414
CLEANDIRS += plugins $(addprefix plugins/, $(PLUGDIRS)) lib/plugins
GENERATED += $(PLUGGENERATED)
415 416 417

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

420 421 422 423
###############
# Why3 commands
###############

Andrei Paskevich's avatar
Andrei Paskevich committed
424 425 426 427 428
TOOLSGENERATED = src/tools/why3wc.ml

TOOLS_BIN = why3config why3execute why3extract why3prove \
	    why3realize why3replay why3wc

Andrei Paskevich's avatar
Andrei Paskevich committed
429
TOOLS_FILES = main $(TOOLS_BIN)
430 431 432 433 434 435 436 437 438 439

TOOLSMODULES = $(addprefix src/tools/, $(TOOLS_FILES))

TOOLSDEP = $(addsuffix .dep, $(TOOLSMODULES))
TOOLSCMO = $(addsuffix .cmo, $(TOOLSMODULES))
TOOLSCMX = $(addsuffix .cmx, $(TOOLSMODULES))

$(TOOLSDEP): DEPFLAGS += -I src/tools
$(TOOLSCMO) $(TOOLSCMX): INCLUDES += -I src/tools

Andrei Paskevich's avatar
Andrei Paskevich committed
440 441
$(TOOLSDEP): $(TOOLSGENERATED)

442 443 444
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

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

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

453 454 455 456 457 458 459 460
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
461
bin/why3execute.opt: lib/why3/why3.cmxa src/tools/why3execute.cmx
462 463 464
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

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

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

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

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

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

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

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

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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
501 502 503 504 505 506 507 508
bin/why3wc.opt: src/tools/why3wc.cmx
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^

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

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
509
clean_old_install::
510
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE)) $(BINDIR)/why3$(EXE)
511
	rm -f $(BINDIR)/why3bench$(EXE) $(BINDIR)/why3replayer$(EXE)
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
512

513
install_no_local::
514
	cp -f bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
515
	cp -f bin/why3config.@OCAMLBEST@  $(TOOLDIR)/why3config$(EXE)
516 517 518
	cp -f bin/why3execute.@OCAMLBEST@ $(TOOLDIR)/why3execute$(EXE)
	cp -f bin/why3extract.@OCAMLBEST@ $(TOOLDIR)/why3extract$(EXE)
	cp -f bin/why3prove.@OCAMLBEST@   $(TOOLDIR)/why3prove$(EXE)
519
	cp -f bin/why3realize.@OCAMLBEST@ $(TOOLDIR)/why3realize$(EXE)
520
	cp -f bin/why3replay.@OCAMLBEST@  $(TOOLDIR)/why3replay$(EXE)
Andrei Paskevich's avatar
Andrei Paskevich committed
521
	cp -f bin/why3wc.@OCAMLBEST@      $(TOOLDIR)/why3wc$(EXE)
522 523

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

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

528
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
529
include $(TOOLSDEP)
530 531
endif

532
depend: $(TOOLSDEP)
533

Andrei Paskevich's avatar
Andrei Paskevich committed
534 535 536
CLEANDIRS += src/tools
GENERATED += $(TOOLSGENERATED)

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
537
clean::
Andrei Paskevich's avatar
Andrei Paskevich committed
538
	rm -f bin/why3*
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
539

540 541 542
##############
# test targets
##############
543

544 545
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
546

547 548
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
549

550 551
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
552

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

556
%.type: %.mlw bin/why3ide.opt
557
	bin/why3.opt --type-only $*.mlw
558

559 560 561 562
##########
# gallery
##########

563
# we export exactly the programs that have a why3session.xml file
564 565 566

.PHONY: gallery

567 568
gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
Andrei Paskevich's avatar
Andrei Paskevich committed
569
	@for x in examples/*/why3session.xml ; do \
570 571
	  d=`dirname $$x`; \
	  f=`basename $$d`; \
572
	  why3 session html $$x; \
573 574
	  echo "exporting $$f"; \
	  mkdir -p $(GALLERYDIR)/$$f; \
575
	  cp examples/$$f.mlw examples/$$f/why3session.html $(GALLERYDIR)/$$f/; \
576
	  rm -f $(GALLERYDIR)/$$f/$$f.zip; \
Andrei Paskevich's avatar
Andrei Paskevich committed
577
	  cd examples/; \
578
	  zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f; \
579
	  cd ..; \
580
	done
581

582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
.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


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

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

.PHONY: xml-validate

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

624 625 626 627 628
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
629 630 631 632
###############
# IDE
###############

633 634
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
635
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
636 637 638

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

Andrei Paskevich's avatar
Andrei Paskevich committed
639
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
640 641 642
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

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

646
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
647

648 649
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
650

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

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

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

662
src/ide/resetgc.o: src/ide/resetgc.c
663 664
	$(if $(QUIET),@echo 'Ocamlc   $<' &&) \
	    $(OCAMLC) -c -ccopt "-Wall -o $@" $<
665

MARCHE Claude's avatar
MARCHE Claude committed
666 667
# depend and clean targets

668
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
669 670
include $(IDEDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
671

Andrei Paskevich's avatar
Andrei Paskevich committed
672
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
673

Andrei Paskevich's avatar
Andrei Paskevich committed
674
CLEANDIRS += src/ide
MARCHE Claude's avatar
MARCHE Claude committed
675

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
676 677 678
clean_old_install::
	rm -f $(BINDIR)/why3ide$(EXE)

679
install_no_local::
680
	cp -f bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
681

682
install_local:: bin/why3ide
683

684
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
685

686 687 688 689
###############
# Session
###############

Andrei Paskevich's avatar
Andrei Paskevich committed
690 691 692
SESSION_FILES = why3session_lib why3session_copy why3session_info \
		why3session_latex why3session_html why3session_rm \
		why3session_output why3session_run why3session_csv \
693
		why3session_main
694 695 696

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

Andrei Paskevich's avatar
Andrei Paskevich committed
697
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
698 699 700
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
701
$(SESSIONDEP): DEPFLAGS += -I src/why3session
702 703 704 705 706 707 708
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

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

713
bin/why3session.byte: lib/why3/why3.cma $(SESSIONCMO)
714
	$(if $(QUIET),@echo 'Linking  $@' &&) \
715
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
716 717 718

# depend and clean targets

719
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
720 721
include $(SESSIONDEP)
endif
722

Andrei Paskevich's avatar
Andrei Paskevich committed
723
depend: $(SESSIONDEP)
724

Andrei Paskevich's avatar
Andrei Paskevich committed
725
CLEANDIRS += src/why3session
726

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
727 728 729
clean_old_install::
	rm -f $(BINDIR)/why3session$(EXE)

730
install_no_local::
731
	cp -f bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
732

733
install_local:: bin/why3session
734

MARCHE Claude's avatar
MARCHE Claude committed
735

736 737 738
##############
# Coq plugin
##############
739

Andrei Paskevich's avatar
Andrei Paskevich committed
740
ifeq (@enable_coq_tactic@,yes)
741

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

Claude Marche's avatar
Claude Marche committed
744
COQP_FILES = coqCompat why3tac g_why3tac
745

746
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
747

748 749 750
COQPDEP = $(addsuffix .dep, $(COQPMODULES))
COQPCMO = $(addsuffix .cmo, $(COQPMODULES))
COQPCMX = $(addsuffix .cmx, $(COQPMODULES))
751

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

755
$(COQPDEP): DEPFLAGS += -I src/coq-tactic
756
$(COQPCMO) $(COQPCMX): INCLUDES += $(COQPINCLUDES)
Andrei Paskevich's avatar
Andrei Paskevich committed
757 758
$(COQPCMO) $(COQPCMX): BFLAGS += -rectypes
$(COQPCMX): OFLAGS += -rectypes
759

760
$(COQPDEP): $(COQPGENERATED)
761

762 763
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
764

Andrei Paskevich's avatar
Andrei Paskevich committed
765 766
src/coq-tactic/coqCompat.ml: src/coq-tactic/coqCompat@coq_compat_version@.ml
	cp -f $< $@
767

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

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

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

780
src/coq-tactic/.why3-vo-byte: lib/coq-tactic/Why3.v lib/coq-tactic/why3tac.cma
Andrei Paskevich's avatar
Andrei Paskevich committed
781
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
782
	    WHY3CONFIG="" $(COQC) -byte -I lib/coq-tactic/ $< && \
783
	    touch src/coq-tactic/.why3-vo-byte
784

785
src/coq-tactic/.why3-vo-opt: lib/coq-tactic/Why3.v lib/coq-tactic/why3tac.cmxs
Andrei Paskevich's avatar
Andrei Paskevich committed
786
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
787
	    WHY3CONFIG="" $(COQC) -opt -I lib/coq-tactic/ $< && \
788
	    touch src/coq-tactic/.why3-vo-opt
789

790
# depend and clean targets
Andrei Paskevich's avatar
Andrei Paskevich committed
791

792
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
793
include $(COQPDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
794
endif
795

796
depend: $(COQPDEP)
797

Andrei Paskevich's avatar
Andrei Paskevich committed
798 799 800 801
CLEANDIRS += src/coq-tactic
CLEANLIBS += lib/coq-tactic/why3tac
GENERATED += $(COQPGENERATED)

802
clean::
803 804
	rm -f lib/coq-tactic/*.vo lib/coq-tactic/*.glob
	rm -f src/coq-tactic/.why3-vo-*
805

806
install_no_local::
807 808
	mkdir -p $(LIBDIR)/why3/coq-tactic
	cp -f lib/coq-tactic/* $(LIBDIR)/why3/coq-tactic
809

810 811 812 813 814 815 816 817
endif

####################
# Coq realizations
####################

ifeq (@enable_coq_libs@,yes)

818
COQLIBS_INT_FILES = Abs ComputerDivision Div2 EuclideanDivision Int MinMax Power
819 820
COQLIBS_INT_ALL_FILES = Exponentiation $(COQLIBS_INT_FILES)
COQLIBS_INT = $(addprefix lib/coq/int/, $(COQLIBS_INT_ALL_FILES))
821

Guillaume Melquiond's avatar