Makefile.in 59 KB
Newer Older
Andrei Paskevich's avatar
Andrei Paskevich committed
1 2 3
####################################################################
#                                                                  #
#  The Why3 Verification Platform   /   The Why3 Development Team  #
Andrei Paskevich's avatar
Andrei Paskevich committed
4
#  Copyright 2010-2013   --   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

Andrei Paskevich's avatar
Andrei Paskevich committed
12
include Version
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
13

14 15 16 17 18 19
VERBOSEMAKE ?= @enable_verbose_make@

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

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

25
prefix	    = @prefix@
26 27 28 29 30
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@

BINDIR  = $(DESTDIR)@bindir@
LIBDIR  = $(DESTDIR)@libdir@
31
DATADIR = $(DESTDIR)@datarootdir@
32
MANDIR  = $(DESTDIR)@mandir@
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
33

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

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

54
DEPFLAGS  = -slash -I lib/why3
55
ifeq (@OCAMLBEST@,opt)
Andrei Paskevich's avatar
Andrei Paskevich committed
56
DEPFLAGS += -native
57 58
endif

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

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

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

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

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

76 77
# external libraries common to all binaries

78
EXTOBJS =
Andrei Paskevich's avatar
Andrei Paskevich committed
79
EXTLIBS = str unix nums dynlink
80 81 82

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
83

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
84 85 86
###############
# main target
###############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
87

88 89 90 91
all: @OCAMLBEST@
plugins: plugins.@OCAMLBEST@
opt: plugins.opt
byte: plugins.byte
Francois Bobot's avatar
Francois Bobot committed
92

93 94 95 96 97
ifeq (@enable_local@,yes)
all: install_local
endif

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

100 101 102
##############
# Why3 library
##############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
103

104
LIBGENERATED = src/util/config.ml src/util/rc.ml src/parser/lexer.ml \
105 106
	       src/parser/parser.mli src/parser/parser.ml \
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
107
	       src/driver/driver_lexer.ml src/session/xml.ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
108

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

113 114
LIB_CORE = ident ty term pattern decl theory \
	   task pretty dterm env trans printer
115

116
LIB_PARSER = ptree glob parser typing lexer
117

118
LIB_DRIVER = call_provers driver_ast driver_parser driver_lexer driver \
119
	     whyconf autodetection
120

121
LIB_TRANSFORM = simplify_formula inlining split_goal induction \
122
		eliminate_definition eliminate_algebraic \
123
		eliminate_inductive eliminate_let eliminate_if \
124 125 126 127
		libencoding discriminate encoding encoding_select \
		encoding_guards_full encoding_tags_full \
		encoding_guards encoding_tags encoding_twin \
		encoding_sort simplify_array filter_trigger \
128
		introduction abstraction close_epsilon lift_epsilon \
129
		eliminate_epsilon \
130
		eval_match instantiate_predicate smoke_detector
131

132
LIB_PRINTER = alt_ergo why3printer smtv1 smtv2 coq pvs isabelle \
133
	      simplify gappa cvc3 yices mathematica
134

François Bobot's avatar
François Bobot committed
135 136
LIB_SESSION = xml termcode session session_tools session_scheduler

137
LIB_WHYML = mlw_ty mlw_expr mlw_decl mlw_pretty mlw_wp mlw_module \
138
	    mlw_dexpr mlw_typing mlw_driver mlw_ocaml \
139
	    mlw_main mlw_interp
140 141

LIBMODULES =  $(addprefix src/util/, $(LIB_UTIL)) \
142 143 144 145
	      $(addprefix src/core/, $(LIB_CORE)) \
	      $(addprefix src/parser/, $(LIB_PARSER)) \
	      $(addprefix src/driver/, $(LIB_DRIVER)) \
	      $(addprefix src/transform/, $(LIB_TRANSFORM)) \
François Bobot's avatar
François Bobot committed
146
	      $(addprefix src/printer/, $(LIB_PRINTER)) \
147 148
	      $(addprefix src/session/, $(LIB_SESSION)) \
	      $(addprefix src/whyml/, $(LIB_WHYML))
149

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

Andrei Paskevich's avatar
Andrei Paskevich committed
153
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
154 155
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
156

Andrei Paskevich's avatar
Andrei Paskevich committed
157
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
158
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
159
$(LIBCMX): OFLAGS += -for-pack Why3
160

161 162
$(LIBDEP): $(LIBGENERATED)

163
# build targets
164

165 166
byte: lib/why3/why3.cma
opt:  lib/why3/why3.cmxa
167

168
lib/why3/why3.cma: lib/why3/why3.cmo
Andrei Paskevich's avatar
Andrei Paskevich committed
169 170
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) -a $(BFLAGS) -o $@ $^
171

172
lib/why3/why3.cmxa: lib/why3/why3.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
173 174
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) -a $(OFLAGS) -o $@ $^
175

176
lib/why3/why3.cmo: $(LIBCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
177 178
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
179

180
lib/why3/why3.cmx: $(LIBCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
181 182
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -pack -o $@ $^
183

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

Andrei Paskevich's avatar
Andrei Paskevich committed
186 187 188
ifneq "$(MAKECMDGOALS)" "clean"
include $(LIBDEP)
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
189

190
depend: $(LIBDEP)
191

Andrei Paskevich's avatar
Andrei Paskevich committed
192
LIBSDIRS = src $(addprefix src/, $(LIBDIRS))
193 194
LIBCLEAN = $(addsuffix /*.cm[iox], $(LIBSDIRS)) \
	   $(addsuffix /*.annot, $(LIBSDIRS)) \
195 196
	   $(addsuffix /*.output, $(LIBSDIRS)) \
	   $(addsuffix /*.automaton, $(LIBSDIRS)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
197
	   $(addsuffix /*.dep, $(LIBSDIRS)) \
198 199 200 201 202
	   $(addsuffix /*.o, $(LIBSDIRS)) \
	   $(addsuffix /*~, $(LIBSDIRS))

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

205 206 207
###############
# installation
###############
208

MARCHE Claude's avatar
MARCHE Claude committed
209 210 211
clean_old_install:
	rm -f $(BINDIR)/why3*
	rm -rf $(DATADIR)/why3
212
	rm -rf $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
213

214 215

install_no_local:: clean_old_install
216
	mkdir -p $(BINDIR)
217
	mkdir -p $(DATADIR)/why3
218
	mkdir -p $(DATADIR)/why3/images
219 220
	mkdir -p $(DATADIR)/why3/images/boomy
	mkdir -p $(DATADIR)/why3/images/fatcow
MARCHE Claude's avatar
MARCHE Claude committed
221
	mkdir -p $(DATADIR)/why3/emacs
222
	mkdir -p $(DATADIR)/why3/vim
223
	mkdir -p $(DATADIR)/why3/lang
MARCHE Claude's avatar
MARCHE Claude committed
224
	mkdir -p $(DATADIR)/why3/theories
225
	mkdir -p $(DATADIR)/why3/modules
MARCHE Claude's avatar
MARCHE Claude committed
226 227
	mkdir -p $(DATADIR)/why3/drivers
	cp -f theories/*.why $(DATADIR)/why3/theories
228
	cp -f modules/*.mlw $(DATADIR)/why3/modules
Andrei Paskevich's avatar
Andrei Paskevich committed
229
	cp -f drivers/*.drv drivers/*.gen $(DATADIR)/why3/drivers
230
	cp -f share/provers-detection-data.conf $(DATADIR)/why3/
231
	cp -f share/images/icons.rc $(DATADIR)/why3/images
232
	cp -f share/images/*.png $(DATADIR)/why3/images
233 234
	cp -f share/images/boomy/*.png $(DATADIR)/why3/images/boomy
	cp -f share/images/fatcow/*.png $(DATADIR)/why3/images/fatcow
235
	cp -f share/why3session.dtd $(DATADIR)/why3
236
	cp -rf share/javascript $(DATADIR)/why3/javascript
237 238 239
	cp -f share/emacs/why3.el $(DATADIR)/why3/emacs/why3.el
	cp -f share/vim/why3.vim $(DATADIR)/why3/vim/why3.vim
	cp -f share/lang/why3.lang $(DATADIR)/why3/lang/why3.lang
240

MARCHE Claude's avatar
MARCHE Claude committed
241
install_no_local_lib::
242
	mkdir -p $(OCAMLINSTALLLIB)/why3
Andrei Paskevich's avatar
Andrei Paskevich committed
243
	cp -f lib/why3/why3.cm* lib/why3/why3.[ao] \
244
		lib/why3/META $(OCAMLINSTALLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
245

246 247
ifeq (@enable_local@,yes)
install install-lib:
248 249
	@echo "Why3 is configured in local installation mode."
	@echo "To install Why3, run ./configure --disable-local ; make ; make install"
250
else
MARCHE Claude's avatar
MARCHE Claude committed
251
install: clean_old_install install_no_local
MARCHE Claude's avatar
MARCHE Claude committed
252
install-lib: install_no_local_lib
253 254
endif

MARCHE Claude's avatar
MARCHE Claude committed
255 256
install-all: install install-lib

257
##################
258
# Why3 plugins
259 260
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
261
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
262 263
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli \
		plugins/parser/dimacs.ml \
264

265
PLUG_PARSER = genequlin dimacs
266
PLUG_PRINTER =
267
PLUG_TRANSFORM =
268
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
269

270
PLUGINS = genequlin dimacs tptp
271

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

Andrei Paskevich's avatar
Andrei Paskevich committed
274 275
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
276

277 278 279 280 281 282 283 284 285 286
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

287 288
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
289
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
290
	      $(TPTPMODULES)
291

Andrei Paskevich's avatar
Andrei Paskevich committed
292
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
293 294 295
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
296
PLUGDIRS = parser printer transform tptp
297 298
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
299
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
300 301
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

302 303
$(PLUGDEP): $(PLUGGENERATED)

304 305 306 307 308
LIBPLUGCMO =  $(addsuffix .cmo,  $(addprefix lib/plugins/, $(PLUGINS)))
LIBPLUGCMXS = $(addsuffix .cmxs, $(addprefix lib/plugins/, $(PLUGINS)))

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
309 310

lib/plugins/%.cmxs: plugins/parser/%.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
311
	$(if $(QUIET),@echo 'Linking  $@' &&) \
312 313 314 315 316 317 318
	    $(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
319
	$(if $(QUIET),@echo 'Linking  $@' &&) \
320 321 322 323 324 325 326
	    $(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
327
	$(if $(QUIET),@echo 'Linking  $@' &&) \
328 329 330 331 332 333
	    $(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
334
lib/plugins/tptp.cmxs: $(TPTPCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
335
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
336
	    $(OCAMLOPT) $(OFLAGS) -shared -o $@ $^
337

Andrei Paskevich's avatar
Andrei Paskevich committed
338
lib/plugins/tptp.cmo: $(TPTPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
339
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
340
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
341 342 343 344 345 346

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
347
	    $(addsuffix /*.dep, $(PLUGSDIRS)) \
348 349 350
	    $(addsuffix /*.o, $(PLUGSDIRS)) \
	    $(addsuffix /*~, $(PLUGSDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
351 352 353 354 355 356
# depend and clean targets

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

357
depend: $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
358

359 360 361 362 363
clean::
	rm -f $(PLUGCLEAN) $(PLUGGENERATED)
	rm -f lib/plugins/*

install_no_local::
364
	rm -rf $(LIBDIR)/why3/plugins
365
	mkdir -p $(LIBDIR)/why3/plugins
366
	cp -f $(foreach f,$(LIBPLUGCMO) $(LIBPLUGCMXS),$(wildcard $(f))) $(LIBDIR)/why3/plugins
367

368 369 370
######
# Why3
######
371

372 373
src/main.cmo: lib/why3/why3.cma
src/main.cmx: lib/why3/why3.cmxa
374

375 376
byte: bin/why3.byte
opt:  bin/why3.opt
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
377

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

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

386 387
bin/why3: bin/why3.@OCAMLBEST@
	ln -sf why3.@OCAMLBEST@ $@
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
388

389 390
install_no_local::
	cp -f bin/why3.@OCAMLBEST@ $(BINDIR)/why3$(EXE)
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
391

392
install_local: bin/why3
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
393

394 395 396 397 398 399
ifneq "$(MAKECMDGOALS)" "clean"
include src/main.dep
endif

depend: src/main.dep

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
400
clean::
401
	rm -f src/main.cm[iox] src/main.annot src/main.o src/main.dep
402
	rm -f bin/why3.byte bin/why3.opt bin/why3
403
	rm -f bin/why3ml.byte bin/why3ml.opt bin/why3ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
404

405 406 407
##############
# test targets
##############
408

409 410
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
411

412 413
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
414

415 416
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
417

418 419
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
420

421
%.type: %.mlw bin/why3ide.opt
422
	bin/why3.opt --type-only $*.mlw
423

424 425 426 427
##########
# gallery
##########

428
# we export exactly the programs that have a why3session.xml file
429 430 431

.PHONY: gallery

432 433
gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
Andrei Paskevich's avatar
Andrei Paskevich committed
434
	@for x in examples/*/why3session.xml ; do \
435 436
	  d=`dirname $$x`; \
	  f=`basename $$d`; \
437
	  why3session html $$x; \
438 439
	  echo "exporting $$f"; \
	  mkdir -p $(GALLERYDIR)/$$f; \
440
	  cp examples/$$f.mlw examples/$$f/$$f.html $(GALLERYDIR)/$$f/; \
441
	  rm -f $(GALLERYDIR)/$$f/$$f.zip; \
Andrei Paskevich's avatar
Andrei Paskevich committed
442
	  cd examples/; \
443
	  zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f/$$f.html  $$f; \
444
	  cd ..; \
445
	done
446

447 448 449 450 451 452 453 454
%-gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
	x=$*/why3session.xml; \
	d=`dirname $$x`; \
	f=`basename $$d`; \
	why3session html $$x; \
	echo "exporting $$f"; \
	mkdir -p $(GALLERYDIR)/$$f; \
455 456 457
	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; \
	cp examples/$$f/$$f.html $(GALLERYDIR)/$$f/; \
458 459 460 461
	rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	cd examples/; \
	zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f/$$f.html  $$f

MARCHE Claude's avatar
MARCHE Claude committed
462 463 464 465 466 467 468 469
########
# XML DTD validation
########

.PHONY: xml-validate

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

473 474 475 476 477
xml-validate-local:
	@for x in `find examples/ -name why3session.xml`; do \
	  xmllint --noout --dtdvalid share/why3session.dtd $$x 2>&1 | head -1; \
	done

478 479 480 481
########
# Config
########

482
CONFIG_FILES = why3config
483

484
CONFIGMODULES = $(addprefix src/why3config/, $(CONFIG_FILES))
485

Andrei Paskevich's avatar
Andrei Paskevich committed
486
CONFIGDEP = $(addsuffix .dep, $(CONFIGMODULES))
487 488 489 490 491
CONFIGCMO = $(addsuffix .cmo, $(CONFIGMODULES))
CONFIGCMX = $(addsuffix .cmx, $(CONFIGMODULES))

# build targets

492 493
byte: bin/why3config.byte
opt:  bin/why3config.opt
494

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

499
bin/why3config.byte: lib/why3/why3.cma $(CONFIGCMO)
500
	$(if $(QUIET),@echo 'Linking  $@' &&) \
501
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
502

503 504 505
bin/why3config: bin/why3config.@OCAMLBEST@
	ln -sf why3config.@OCAMLBEST@ $@

506 507
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
508 509 510
ifneq "$(MAKECMDGOALS)" "clean"
include $(CONFIGDEP)
endif
511

Andrei Paskevich's avatar
Andrei Paskevich committed
512
depend: $(CONFIGDEP)
513 514

clean::
515 516 517
	rm -f src/why3config/*.cm[iox] src/why3config/*.o
	rm -f src/why3config/*.annot src/why3config/*.dep src/why3config/*~
	rm -f src/why3config/*.output src/why3config/*.automaton
518
	rm -f bin/why3config.byte bin/why3config.opt bin/why3config
519

520 521
local_config: bin/why3config.@OCAMLBEST@
	WHY3LIB=$(PWD) WHY3DATA=$(PWD)/share bin/why3config.@OCAMLBEST@ \
522
		--detect --conf_file why3.conf
523

524
install_no_local::
525
	cp -f bin/why3config.@OCAMLBEST@ $(BINDIR)/why3config$(EXE)
526

527
install_local: bin/why3config
528

MARCHE Claude's avatar
MARCHE Claude committed
529 530 531 532
###############
# IDE
###############

533 534
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
535
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
536 537 538

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

Andrei Paskevich's avatar
Andrei Paskevich committed
539
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
540 541 542
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

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

546
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
547

548 549
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
550

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

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

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

562 563 564
bin/why3ide: bin/why3ide.@OCAMLBEST@
	ln -sf why3ide.@OCAMLBEST@ $@

565
src/ide/resetgc.o: src/ide/resetgc.c
566
	$(OCAMLC) -c -ccopt "-Wall -o $@" $<
567

MARCHE Claude's avatar
MARCHE Claude committed
568 569
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
570 571 572
ifneq "$(MAKECMDGOALS)" "clean"
include $(IDEDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
573

Andrei Paskevich's avatar
Andrei Paskevich committed
574
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
575 576

clean::
577
	rm -f src/ide/xml.ml
MARCHE Claude's avatar
MARCHE Claude committed
578
	rm -f src/ide/*.cm[iox] src/ide/*.o
Andrei Paskevich's avatar
Andrei Paskevich committed
579
	rm -f src/ide/*.annot src/ide/*.dep src/ide/*~
580
	rm -f bin/why3ide.byte bin/why3ide.opt bin/why3ide
MARCHE Claude's avatar
MARCHE Claude committed
581

582
install_no_local::
583
	cp -f bin/why3ide.@OCAMLBEST@ $(BINDIR)/why3ide$(EXE)
584 585

install_local: bin/why3ide
586

587
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
588

589

MARCHE Claude's avatar
MARCHE Claude committed
590 591 592 593
###############
# Replayer
###############

François Bobot's avatar
François Bobot committed
594
REPLAYER_FILES = replay
MARCHE Claude's avatar
MARCHE Claude committed
595

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

Andrei Paskevich's avatar
Andrei Paskevich committed
598
REPLAYERDEP = $(addsuffix .dep, $(REPLAYERMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
599 600 601
REPLAYERCMO = $(addsuffix .cmo, $(REPLAYERMODULES))
REPLAYERCMX = $(addsuffix .cmx, $(REPLAYERMODULES))

602 603
$(REPLAYERDEP): DEPFLAGS += -I src/why3replayer
$(REPLAYERCMO) $(REPLAYERCMX): INCLUDES += -I src/why3replayer
MARCHE Claude's avatar
MARCHE Claude committed
604 605 606 607 608 609

# build targets

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

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

614
bin/why3replayer.byte: lib/why3/why3.cma $(REPLAYERCMO)
MARCHE Claude's avatar
MARCHE Claude committed
615
	$(if $(QUIET),@echo 'Linking  $@' &&) \
616
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
MARCHE Claude's avatar
MARCHE Claude committed
617 618 619 620 621 622

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

# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
623 624 625
ifneq "$(MAKECMDGOALS)" "clean"
include $(REPLAYERDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
626

Andrei Paskevich's avatar
Andrei Paskevich committed
627
depend: $(REPLAYERDEP)
MARCHE Claude's avatar
MARCHE Claude committed
628 629

clean::
630 631
	rm -f src/why3replayer/*.cm[iox] src/why3replayer/*.o
	rm -f src/why3replayer/*.annot src/why3replayer/*.dep src/why3replayer/*~
MARCHE Claude's avatar
MARCHE Claude committed
632 633 634
	rm -f bin/why3replayer.byte bin/why3replayer.opt bin/why3replayer

install_no_local::
635
	cp -f bin/why3replayer.@OCAMLBEST@ $(BINDIR)/why3replayer$(EXE)
MARCHE Claude's avatar
MARCHE Claude committed
636 637 638

install_local: bin/why3replayer

639 640 641 642 643

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

644 645
SESSION_FILES = why3session_lib why3session_copy why3session_info	\
		why3session_latex why3session_html why3session_rm	\
646 647
		why3session_output why3session_run why3session_csv	\
		why3session
648 649 650

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

Andrei Paskevich's avatar
Andrei Paskevich committed
651
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
652 653 654
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
655
$(SESSIONDEP): DEPFLAGS += -I src/why3session
656 657 658 659 660 661 662
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

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

667
bin/why3session.byte: lib/why3/why3.cma $(SESSIONCMO)
668
	$(if $(QUIET),@echo 'Linking  $@' &&) \
669
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
670 671 672 673 674 675

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

# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
676 677 678
ifneq "$(MAKECMDGOALS)" "clean"
include $(SESSIONDEP)
endif
679

Andrei Paskevich's avatar
Andrei Paskevich committed
680
depend: $(SESSIONDEP)
681 682

clean::
Andrei Paskevich's avatar
Andrei Paskevich committed
683 684
	rm -f src/why3session/*.cm[iox] src/why3session/*.o
	rm -f src/why3session/*.annot src/why3session/*.dep src/why3session/*~
685 686 687 688 689 690 691
	rm -f bin/why3session.byte bin/why3session.opt bin/why3session

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

install_local: bin/why3session

MARCHE Claude's avatar
MARCHE Claude committed
692

693
###############
694
# Bench
695 696
###############

697 698
ifeq (@enable_bench@,yes)

699
BENCH_FILES = worker db bench benchrc benchdb why3bench
700

701
BENCHMODULES := $(addprefix src/why3bench/, $(BENCH_FILES))
702

Andrei Paskevich's avatar
Andrei Paskevich committed
703
BENCHDEP = $(addsuffix .dep, $(BENCHMODULES))
704 705 706
BENCHCMO = $(addsuffix .cmo, $(BENCHMODULES))
BENCHCMX = $(addsuffix .cmx, $(BENCHMODULES))

707 708
$(BENCHDEP): DEPFLAGS += -I src/why3bench
$(BENCHCMO) $(BENCHCMX): INCLUDES += -I src/why3bench -I @SQLITE3LIB@
709 710 711

# build targets

712 713
byte: bin/why3bench.byte
opt:  bin/why3bench.opt
714

Andrei Paskevich's avatar
Andrei Paskevich committed
715
bin/why3bench.opt bin/why3bench.byte: INCLUDES += -thread -I +threads -I @SQLITE3LIB@
716
bin/why3bench.opt bin/why3bench.byte: EXTLIBS += threads sqlite3
717

718
bin/why3bench.opt: lib/why3/why3.cmxa $(BENCHCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
719
	$(if $(QUIET),@echo 'Linking  $@' &&) \
720
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
721

722
bin/why3bench.byte: lib/why3/why3.cma $(BENCHCMO)
723
	$(if $(QUIET),@echo 'Linking  $@' &&) \
724
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
725

726 727 728
bin/why3bench: bin/why3bench.@OCAMLBEST@
	ln -sf why3bench.@OCAMLBEST@ $@

729 730
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
731 732 733
ifneq "$(MAKECMDGOALS)" "clean"
include $(BENCHDEP)
endif
734

Andrei Paskevich's avatar
Andrei Paskevich committed
735
depend: $(BENCHDEP)
736 737

clean::
738 739
	rm -f src/why3bench/*.cm[iox] src/why3bench/*.o
	rm -f src/why3bench/*.annot src/why3bench/*.dep src/why3bench/*~
740
	rm -f bin/why3bench.byte bin/why3bench.opt bin/why3bench
741 742

install_no_local::
743
	cp -f bin/why3bench.@OCAMLBEST@ $(BINDIR)/why3bench$(EXE)
744 745

install_local: bin/why3bench
746

747 748
endif

749 750 751
##############
# Coq plugin
##############
752

Andrei Paskevich's avatar
Andrei Paskevich committed
753
ifeq (@enable_coq_tactic@,yes)
754

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

Claude Marche's avatar
Claude Marche committed
757
COQP_FILES = coqCompat why3tac g_why3tac
758

759
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
760

761 762 763
COQPDEP = $(addsuffix .dep, $(COQPMODULES))
COQPCMO = $(addsuffix .cmo, $(COQPMODULES))
COQPCMX = $(addsuffix .cmx, $(COQPMODULES))
764

765
COQPTREES = kernel lib interp parsing proofs pretyping tactics library toplevel
Andrei Paskevich's avatar
Andrei Paskevich committed
766
COQPINCLUDES = -I src/coq-tactic -I +camlp5 $(addprefix -I @COQLIB@/, $(COQPTREES))
767

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

773
$(COQPDEP): $(COQPGENERATED)
774

775 776
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
777

Andrei Paskevich's avatar
Andrei Paskevich committed
778 779
src/coq-tactic/coqCompat.ml: src/coq-tactic/coqCompat@coq_compat_version@.ml
	cp -f $< $@
780

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

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

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

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

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

803
# depend and clean targets
Andrei Paskevich's avatar
Andrei Paskevich committed
804