Makefile.in 58.8 KB
Newer Older
Andrei Paskevich's avatar
Andrei Paskevich committed
1 2 3
####################################################################
#                                                                  #
#  The Why3 Verification Platform   /   The Why3 Development Team  #
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
4
#  Copyright 2010-2014   --   INRIA - CNRS - Paris-Sud University  #
Andrei Paskevich's avatar
Andrei Paskevich committed
5 6 7 8 9 10
#                                                                  #
#  This software is distributed under the terms of the GNU Lesser  #
#  General Public License version 2.1, with the special exception  #
#  on linking described in file LICENSE.                           #
#                                                                  #
####################################################################
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
11

12 13 14 15 16 17
VERBOSEMAKE ?= @enable_verbose_make@

ifeq ($(VERBOSEMAKE),yes)
  QUIET =
else
  QUIET = yes
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
18 19
endif

20
# install the binaries
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
21
DESTDIR =
22

23
prefix	    = @prefix@
24 25 26 27 28
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@

BINDIR  = $(DESTDIR)@bindir@
LIBDIR  = $(DESTDIR)@libdir@
29
DATADIR = $(DESTDIR)@datarootdir@
30
MANDIR  = $(DESTDIR)@mandir@
31
TOOLDIR = $(LIBDIR)/why3/commands
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
32

Andrei Paskevich's avatar
Andrei Paskevich committed
33
# OS specific stuff
34
EXE   = @EXE@
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
35 36

# other variables
37
CC        = @CC@
38 39 40 41 42 43 44
OCAMLC    = @OCAMLC@
OCAMLOPT  = @OCAMLOPT@
OCAMLDEP  = @OCAMLDEP@
OCAMLLEX  = @OCAMLLEX@
OCAMLYACC = @OCAMLYACC@
OCAMLDOC  = @OCAMLDOC@
OCAMLLIB  = @OCAMLLIB@
45
OCAMLINSTALLLIB  = $(DESTDIR)@OCAMLINSTALLLIB@
46 47
OCAMLBEST = @OCAMLBEST@
OCAMLVERSION = @OCAMLVERSION@
48 49
COQC      = @COQC@
COQDEP    = @COQDEP@
50
CAMLP5O   = @CAMLP5O@
MARCHE Claude's avatar
MARCHE Claude committed
51
FRAMAC_LIBDIR = $(DESTDIR)@FRAMAC_LIBDIR@
52

53
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 79 80 81
ifeq (@enable_bin_annot@,yes)
OFLAGS += -bin-annot
BFLAGS += -bin-annot
endif

82 83
# external libraries common to all binaries

84
EXTOBJS =
85
EXTLIBS = str unix nums dynlink @ZIPLIB@
86 87 88

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
89

Andrei Paskevich's avatar
Andrei Paskevich committed
90
INSTALLED_LIB_EXTS = a cma cmx cmi cmxa cmxs
91
COMPILED_LIB_EXTS = $(INSTALLED_LIB_EXTS) o cmo cmt cmti annot dep output
Andrei Paskevich's avatar
Andrei Paskevich committed
92

93 94
TARGET_EMACS = share/emacs/why3.elc

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
95 96 97
###############
# main target
###############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
98

99 100 101 102
all: @OCAMLBEST@
plugins: plugins.@OCAMLBEST@
opt: plugins.opt
byte: plugins.byte
Francois Bobot's avatar
Francois Bobot committed
103

104 105 106 107 108
ifeq (@enable_local@,yes)
all: install_local
endif

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

Andrei Paskevich's avatar
Andrei Paskevich committed
111 112 113 114
CLEANDIRS =
CLEANLIBS =
GENERATED =

115 116 117
##############
# Why3 library
##############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
118

119
LIBGENERATED = src/util/config.ml \
120
	       src/util/rc.ml src/util/lexlib.ml src/parser/lexer.ml \
121 122
	       src/parser/parser.mli src/parser/parser.ml \
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
123
	       src/driver/driver_lexer.ml \
124
	       src/session/compress.ml src/session/xml.ml \
125
	       src/session/strategy_parser.ml \
126
	       lib/ocaml/why3__BigInt_compat.ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
127

128 129
LIB_UTIL = config bigInt util opt lists strings \
	   extmap extset exthtbl weakhtbl \
130
	   hashcons stdlib exn_printer pp debug loc lexlib print_tree \
131
	   cmdline warning sysutil rc plugin bigInt number pqueue
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
132

133 134
LIB_CORE = ident ty term pattern decl theory \
	   task pretty dterm env trans printer
135

136
LIB_DRIVER = call_provers driver_ast driver_parser driver_lexer driver \
137
	     whyconf autodetection
138

139
LIB_MLW = ity
140

141 142
LIB_PARSER = ptree glob parser typing lexer

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

155
LIB_PRINTER = alt_ergo why3printer smtv1 smtv2 coq pvs isabelle \
156
	      simplify gappa cvc3 yices mathematica
157

158
LIB_WHYML = mlw_ty mlw_expr mlw_decl mlw_pretty mlw_wp mlw_module \
159
	    mlw_dexpr mlw_typing mlw_driver mlw_ocaml \
160
	    mlw_main mlw_interp
161

162 163 164
LIB_SESSION = compress xml termcode session session_tools strategy \
              strategy_parser session_scheduler

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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
178
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
179 180
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
181

Andrei Paskevich's avatar
Andrei Paskevich committed
182
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
183
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
184
$(LIBCMX): OFLAGS += -for-pack Why3
185

186 187
$(LIBDEP): $(LIBGENERATED)

188 189 190
# Zarith

ifeq (@enable_zarith@,yes)
191
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_zarith.ml
192
	cp lib/ocaml/why3__BigInt_zarith.ml $@
193
else
194
lib/ocaml/why3__BigInt_compat.ml: config.status lib/ocaml/why3__BigInt_num.ml
195
	cp lib/ocaml/why3__BigInt_num.ml $@
196 197
endif

198 199 200 201 202 203 204 205 206 207
# 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

208
# build targets
209

210 211
byte: lib/why3/why3.cma
opt:  lib/why3/why3.cmxa
212

213
lib/why3/why3.cma: lib/why3/why3.cmo
Andrei Paskevich's avatar
Andrei Paskevich committed
214 215
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) -a $(BFLAGS) -o $@ $^
216

217
lib/why3/why3.cmxa: lib/why3/why3.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
218 219
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) -a $(OFLAGS) -o $@ $^
220

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

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

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

231
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
232
include $(LIBDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
233
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
234

235
depend: $(LIBDEP)
236

Andrei Paskevich's avatar
Andrei Paskevich committed
237 238 239
CLEANDIRS += src $(addprefix src/, $(LIBDIRS))
CLEANLIBS += lib/why3/why3session lib/why3/why3
GENERATED += $(LIBGENERATED)
240

241 242 243
###############
# installation
###############
244

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

250

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

MARCHE Claude's avatar
MARCHE Claude committed
283
install_no_local_lib::
284
	mkdir -p $(OCAMLINSTALLLIB)/why3
Andrei Paskevich's avatar
Andrei Paskevich committed
285
	cp -f $(addprefix lib/why3/why3., $(INSTALLED_LIB_EXTS)) \
286
		lib/why3/META $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
287

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

MARCHE Claude's avatar
MARCHE Claude committed
297 298
install-all: install install-lib

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
299 300 301 302 303 304
##################
# Uninstallation
##################

uninstall: clean_old_install

305 306 307 308 309 310 311
##################
# Why3 emacs mode
##################

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

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


325
##################
326
# Why3 plugins
327 328
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
329
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
330 331
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
		plugins/parser/dimacs.ml \
332

333
PLUG_PARSER = genequlin dimacs
334
PLUG_PRINTER =
335
PLUG_TRANSFORM =
336
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
337

338
PLUGINS = genequlin dimacs tptp
339

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

Andrei Paskevich's avatar
Andrei Paskevich committed
342 343
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
344

345 346 347 348 349 350 351 352 353 354
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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
360
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
361 362 363
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
364
PLUGDIRS = parser printer transform tptp
365 366
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
367
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
368 369
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

370 371
$(PLUGDEP): $(PLUGGENERATED)

372 373 374 375 376
LIBPLUGCMO =  $(addsuffix .cmo,  $(addprefix lib/plugins/, $(PLUGINS)))
LIBPLUGCMXS = $(addsuffix .cmxs, $(addprefix lib/plugins/, $(PLUGINS)))

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
377 378

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

Andrei Paskevich's avatar
Andrei Paskevich committed
406
lib/plugins/tptp.cmo: $(TPTPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
407
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
408
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
409

Andrei Paskevich's avatar
Andrei Paskevich committed
410 411
# depend and clean targets

412
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
413 414 415
include $(PLUGDEP)
endif

416
depend: $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
417

Andrei Paskevich's avatar
Andrei Paskevich committed
418 419
CLEANDIRS += plugins $(addprefix plugins/, $(PLUGDIRS)) lib/plugins
GENERATED += $(PLUGGENERATED)
420 421 422

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

425 426 427 428
###############
# Why3 commands
###############

Andrei Paskevich's avatar
Andrei Paskevich committed
429 430 431 432 433
TOOLSGENERATED = src/tools/why3wc.ml

TOOLS_BIN = why3config why3execute why3extract why3prove \
	    why3realize why3replay why3wc

Andrei Paskevich's avatar
Andrei Paskevich committed
434
TOOLS_FILES = main $(TOOLS_BIN)
435 436 437 438 439 440 441 442 443 444

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
445 446
$(TOOLSDEP): $(TOOLSGENERATED)

447 448 449
byte: bin/why3.byte $(TOOLS_BIN:%=bin/%.byte)
opt:  bin/why3.opt  $(TOOLS_BIN:%=bin/%.opt)

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

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

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

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

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

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

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

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

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

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

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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
506 507 508 509 510 511 512 513
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
514
clean_old_install::
515
	rm -f $(TOOLS_BIN:%=$(TOOLDIR)/%$(EXE)) $(BINDIR)/why3$(EXE)
516
	rm -f $(BINDIR)/why3bench$(EXE) $(BINDIR)/why3replayer$(EXE)
Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
517

518
install_no_local::
519
	cp -f bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
520
	cp -f bin/why3config.@OCAMLBEST@  $(TOOLDIR)/why3config$(EXE)
521 522 523
	cp -f bin/why3execute.@OCAMLBEST@ $(TOOLDIR)/why3execute$(EXE)
	cp -f bin/why3extract.@OCAMLBEST@ $(TOOLDIR)/why3extract$(EXE)
	cp -f bin/why3prove.@OCAMLBEST@   $(TOOLDIR)/why3prove$(EXE)
524
	cp -f bin/why3realize.@OCAMLBEST@ $(TOOLDIR)/why3realize$(EXE)
525
	cp -f bin/why3replay.@OCAMLBEST@  $(TOOLDIR)/why3replay$(EXE)
Andrei Paskevich's avatar
Andrei Paskevich committed
526
	cp -f bin/why3wc.@OCAMLBEST@      $(TOOLDIR)/why3wc$(EXE)
527 528

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

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

533
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
534
include $(TOOLSDEP)
535 536
endif

537
depend: $(TOOLSDEP)
538

Andrei Paskevich's avatar
Andrei Paskevich committed
539 540 541
CLEANDIRS += src/tools
GENERATED += $(TOOLSGENERATED)

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
542
clean::
Andrei Paskevich's avatar
Andrei Paskevich committed
543
	rm -f bin/why3*
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
544

545 546 547
##############
# test targets
##############
548

549 550
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
551

552 553
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
554

555 556
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
557

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

561
%.type: %.mlw bin/why3ide.opt
562
	bin/why3.opt --type-only $*.mlw
563

564 565 566 567
##########
# gallery
##########

568
# we export exactly the programs that have a why3session.xml file
569 570 571

.PHONY: gallery

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

587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602
.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


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

MARCHE Claude's avatar
MARCHE Claude committed
618 619 620 621 622 623 624 625
########
# XML DTD validation
########

.PHONY: xml-validate

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

629 630 631 632 633
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
634 635 636 637
###############
# IDE
###############

638 639
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
640
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
641 642 643

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

Andrei Paskevich's avatar
Andrei Paskevich committed
644
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
645 646 647
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

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

651
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
652

653 654
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
655

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

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

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

667
src/ide/resetgc.o: src/ide/resetgc.c
668 669
	$(if $(QUIET),@echo 'Ocamlc   $<' &&) \
	    $(OCAMLC) -c -ccopt "-Wall -o $@" $<
670

MARCHE Claude's avatar
MARCHE Claude committed
671 672
# depend and clean targets

673
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
674 675
include $(IDEDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
676

Andrei Paskevich's avatar
Andrei Paskevich committed
677
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
678

Andrei Paskevich's avatar
Andrei Paskevich committed
679
CLEANDIRS += src/ide
MARCHE Claude's avatar
MARCHE Claude committed
680

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
681 682 683
clean_old_install::
	rm -f $(BINDIR)/why3ide$(EXE)

684
install_no_local::
685
	cp -f bin/why3ide.@OCAMLBEST@ $(TOOLDIR)/why3ide$(EXE)
686

687
install_local:: bin/why3ide
688

689
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
690

691 692 693 694
###############
# Session
###############

Andrei Paskevich's avatar
Andrei Paskevich committed
695 696 697
SESSION_FILES = why3session_lib why3session_copy why3session_info \
		why3session_latex why3session_html why3session_rm \
		why3session_output why3session_run why3session_csv \
698
		why3session_main
699 700 701

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

Andrei Paskevich's avatar
Andrei Paskevich committed
702
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
703 704 705
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
706
$(SESSIONDEP): DEPFLAGS += -I src/why3session
707 708 709 710 711 712 713
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

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

718
bin/why3session.byte: lib/why3/why3.cma $(SESSIONCMO)
719
	$(if $(QUIET),@echo 'Linking  $@' &&) \
720
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
721 722 723

# depend and clean targets

724
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
Andrei Paskevich's avatar
Andrei Paskevich committed
725 726
include $(SESSIONDEP)
endif
727

Andrei Paskevich's avatar
Andrei Paskevich committed
728
depend: $(SESSIONDEP)
729

Andrei Paskevich's avatar
Andrei Paskevich committed
730
CLEANDIRS += src/why3session
731

Jacques-Pascal Deplaix's avatar
Jacques-Pascal Deplaix committed
732 733 734
clean_old_install::
	rm -f $(BINDIR)/why3session$(EXE)

735
install_no_local::
736
	cp -f bin/why3session.@OCAMLBEST@ $(TOOLDIR)/why3session$(EXE)
737

738
install_local:: bin/why3session
739

MARCHE Claude's avatar
MARCHE Claude committed
740

741 742 743
##############
# Coq plugin
##############
744

Andrei Paskevich's avatar
Andrei Paskevich committed
745
ifeq (@enable_coq_tactic@,yes)
746

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

Claude Marche's avatar
Claude Marche committed
749
COQP_FILES = coqCompat why3tac g_why3tac
750

751
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
752

753 754 755
COQPDEP = $(addsuffix .dep, $(COQPMODULES))
COQPCMO = $(addsuffix .cmo, $(COQPMODULES))
COQPCMX = $(addsuffix .cmx, $(COQPMODULES))
756

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

760
$(COQPDEP): DEPFLAGS += -I src/coq-tactic
761
$(COQPCMO) $(COQPCMX): INCLUDES += $(COQPINCLUDES)
Andrei Paskevich's avatar
Andrei Paskevich committed
762 763
$(COQPCMO) $(COQPCMX): BFLAGS += -rectypes
$(COQPCMX): OFLAGS += -rectypes
764

765
$(COQPDEP): $(COQPGENERATED)
766

767 768
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
769

Andrei Paskevich's avatar
Andrei Paskevich committed
770 771
src/coq-tactic/coqCompat.ml: src/coq-tactic/coqCompat@coq_compat_version@.ml
	cp -f $< $@
772

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

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

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

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

790
src/coq-tactic/.why3-vo-opt: lib/coq-tactic/Why3.v lib/coq-tactic/why3tac.cmxs
Andrei Paskevich's avatar
Andrei Paskevich committed
791
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
792
	    WHY3CONFIG="" $(COQC) -opt -I lib/coq-tactic/ $< && \
793
	    touch src/coq-tactic/.why3-vo-opt
794

795
# depend and clean targets
Andrei Paskevich's avatar
Andrei Paskevich committed
796

797
ifneq "$(MAKECMDGOALS:clean%=clean)" "clean"
798
include $(COQPDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
799
endif
800

801
depend: $(COQPDEP)
802

Andrei Paskevich's avatar
Andrei Paskevich committed
803 804 805 806
CLEANDIRS += src/coq-tactic
CLEANLIBS += lib/coq-tactic/why3tac
GENERATED += $(COQPGENERATED)

807
clean::
808 809
	rm -f lib/coq-tactic/*.vo lib/coq-tactic/*.glob
	rm -f src/coq-tactic/.why3-vo-*
810

811
install_no_local::
812 813
	mkdir -p $(LIBDIR)/why3/coq-tactic
	cp -f lib/coq-tactic/* $(LIBDIR)/why3/coq-tactic
814

815 816 817 818 819 820 821 822
endif

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

ifeq (@enable_coq_libs@,yes)