Makefile.in 45.5 KB
Newer Older
Andrei Paskevich's avatar
Andrei Paskevich committed
1 2 3 4 5 6 7 8 9 10
####################################################################
#                                                                  #
#  The Why3 Verification Platform   /   The Why3 Development Team  #
#  Copyright 2010-2012   --   INRIA - CNRS - Paris-Sud University  #
#                                                                  #
#  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 46 47
OCAMLC    = @OCAMLC@
OCAMLOPT  = @OCAMLOPT@
OCAMLDEP  = @OCAMLDEP@
OCAMLLEX  = @OCAMLLEX@
OCAMLYACC = @OCAMLYACC@
OCAMLDOC  = @OCAMLDOC@
OCAMLLIB  = @OCAMLLIB@
OCAMLBEST = @OCAMLBEST@
OCAMLVERSION = @OCAMLVERSION@
48 49
COQC      = @COQC@
COQDEP    = @COQDEP@
50 51
CAMLP5O   = @CAMLP5O@

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

57
RUBBER = @RUBBER@
58
HEVEA = @HEVEA@
59
HACHA = @HACHA@
60

61
#PSVIEWER  = @PSVIEWER@
Andrei Paskevich's avatar
Andrei Paskevich committed
62
#PDFVIEWER = @PDFVIEWER@
63

Andrei Paskevich's avatar
Andrei Paskevich committed
64
OFLAGS = -w Aer-29 -dtypes -g -I lib/why3 $(INCLUDES)
65
BFLAGS = -w Aer-29 -dtypes -g -I lib/why3 $(INCLUDES)
66 67 68

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

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

74 75
# external libraries common to all binaries

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

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
81

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
82 83 84
###############
# main target
###############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
85

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

91 92 93 94 95
ifeq (@enable_local@,yes)
all: install_local
endif

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

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
98
#############
99
# Why library
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
100
#############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
101

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

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

111
LIB_CORE = ident ty term pattern decl theory task pretty env trans printer
112

113
LIB_PARSER = ptree denv glob parser typing lexer
114

115
LIB_DRIVER = call_provers driver_ast driver_parser driver_lexer driver \
116
	     whyconf autodetection
117

118
LIB_TRANSFORM = simplify_recursive_definition simplify_formula \
Leon Gondelman's avatar
Leon Gondelman committed
119
		inlining split_goal induction \
120
		eliminate_definition eliminate_algebraic \
121
		eliminate_inductive eliminate_let eliminate_if \
122
		libencoding discriminate protect_finite \
123
		encoding encoding_select \
124
		encoding_decorate encoding_decoexp encoding_twin \
François Bobot's avatar
François Bobot committed
125
		encoding_explicit encoding_guard encoding_sort \
126
		encoding_instantiate simplify_array filter_trigger \
127
		introduction abstraction close_epsilon lift_epsilon \
128
		eval_match instantiate_predicate smoke_detector
129

130
LIB_PRINTER = alt_ergo why3printer smtv1 smtv2 coq pvs \
Daisuke Ishii's avatar
Daisuke Ishii committed
131
		simplify gappa cvc3 yices mathematica
132

François Bobot's avatar
François Bobot committed
133 134
LIB_SESSION = xml termcode session session_tools session_scheduler

135 136 137 138
LIB_WHYML = mlw_ty mlw_expr mlw_decl mlw_pretty mlw_wp mlw_module \
	    mlw_dtree mlw_dty mlw_typing mlw_driver mlw_ocaml mlw_main

LIBMODULES =  $(addprefix src/util/, $(LIB_UTIL)) \
139 140 141 142
	      $(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
143
	      $(addprefix src/printer/, $(LIB_PRINTER)) \
144 145
	      $(addprefix src/session/, $(LIB_SESSION)) \
	      $(addprefix src/whyml/, $(LIB_WHYML))
146

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

Andrei Paskevich's avatar
Andrei Paskevich committed
150
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
151 152
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
153

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

158 159
$(LIBDEP): $(LIBGENERATED)

160
# build targets
161

162 163
byte: lib/why3/why3.cma
opt:  lib/why3/why3.cmxa
164

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

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

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

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

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

Andrei Paskevich's avatar
Andrei Paskevich committed
183 184 185
ifneq "$(MAKECMDGOALS)" "clean"
include $(LIBDEP)
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
186

187
depend: $(LIBDEP)
188

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

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

202 203 204
###############
# installation
###############
205

MARCHE Claude's avatar
MARCHE Claude committed
206 207 208 209
clean_old_install:
	rm -f $(BINDIR)/why3*
	rm -rf $(DATADIR)/why3

210
install_no_local::
211
	mkdir -p $(BINDIR)
212
	mkdir -p $(DATADIR)/why3
213
	mkdir -p $(DATADIR)/why3/images
214 215
	mkdir -p $(DATADIR)/why3/images/boomy
	mkdir -p $(DATADIR)/why3/images/fatcow
MARCHE Claude's avatar
MARCHE Claude committed
216
	mkdir -p $(DATADIR)/why3/emacs
217
	mkdir -p $(DATADIR)/why3/lang
MARCHE Claude's avatar
MARCHE Claude committed
218
	mkdir -p $(DATADIR)/why3/theories
219
	mkdir -p $(DATADIR)/why3/modules
MARCHE Claude's avatar
MARCHE Claude committed
220 221
	mkdir -p $(DATADIR)/why3/drivers
	cp -f theories/*.why $(DATADIR)/why3/theories
222
	cp -f modules/*.mlw $(DATADIR)/why3/modules
Andrei Paskevich's avatar
Andrei Paskevich committed
223
	cp -f drivers/*.drv drivers/*.gen $(DATADIR)/why3/drivers
224
	cp -f share/provers-detection-data.conf $(DATADIR)/why3/
225
	cp -f share/images/icons.rc $(DATADIR)/why3/images
226
	cp -f share/images/*.png $(DATADIR)/why3/images
227 228
	cp -f share/images/boomy/*.png $(DATADIR)/why3/images/boomy
	cp -f share/images/fatcow/*.png $(DATADIR)/why3/images/fatcow
229
	cp -f share/why3session.dtd $(DATADIR)/why3
230
	cp -rf share/javascript $(DATADIR)/why3/javascript
MARCHE Claude's avatar
MARCHE Claude committed
231
	cp -f share/emacs/why.el $(DATADIR)/why3/emacs/why.el
232
	cp -f share/lang/why.lang $(DATADIR)/why3/lang/why.lang
233
#	if test -d /etc/bash_completion.d; then cp -f share/bash/why3 /etc/bash_completion.d; fi
234

MARCHE Claude's avatar
MARCHE Claude committed
235
install_no_local_lib::
236
	rm -rf $(OCAMLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
237
	mkdir -p $(OCAMLLIB)/why3
Andrei Paskevich's avatar
Andrei Paskevich committed
238 239
	cp -f lib/why3/why3.cm* lib/why3/why3.[ao] \
		lib/why3/META $(OCAMLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
240

241 242 243 244 245
ifeq (@enable_local@,yes)
install install-lib:
	@echo "Why is configured in local installation mode."
	@echo "To install Why, run ./configure --disable-local ; make ; make install"
else
MARCHE Claude's avatar
MARCHE Claude committed
246
install: clean_old_install install_no_local
MARCHE Claude's avatar
MARCHE Claude committed
247
install-lib: install_no_local_lib
248 249
endif

MARCHE Claude's avatar
MARCHE Claude committed
250 251
install-all: install install-lib

252 253 254 255
##################
# Why plugins
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
256 257
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli
258 259

PLUG_PARSER = genequlin
260
PLUG_PRINTER =
261
PLUG_TRANSFORM =
262
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
263

264
PLUGINS = genequlin tptp
265

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

Andrei Paskevich's avatar
Andrei Paskevich committed
268 269
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
270

271 272 273 274 275 276 277 278 279 280
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

281 282
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
283
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
284
	      $(TPTPMODULES)
285

Andrei Paskevich's avatar
Andrei Paskevich committed
286
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
287 288 289
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
290
PLUGDIRS = parser printer transform tptp
291 292
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
293
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
294 295
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

296 297
$(PLUGDEP): $(PLUGGENERATED)

298 299 300 301 302
LIBPLUGCMO =  $(addsuffix .cmo,  $(addprefix lib/plugins/, $(PLUGINS)))
LIBPLUGCMXS = $(addsuffix .cmxs, $(addprefix lib/plugins/, $(PLUGINS)))

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
303 304

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

Andrei Paskevich's avatar
Andrei Paskevich committed
332
lib/plugins/tptp.cmo: $(TPTPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
333
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
334
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
335 336 337 338 339 340

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
341
	    $(addsuffix /*.dep, $(PLUGSDIRS)) \
342 343 344
	    $(addsuffix /*.o, $(PLUGSDIRS)) \
	    $(addsuffix /*~, $(PLUGSDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
345 346 347 348 349 350
# depend and clean targets

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

351
depend: $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
352

353 354 355 356 357
clean::
	rm -f $(PLUGCLEAN) $(PLUGGENERATED)
	rm -f lib/plugins/*

install_no_local::
358
	rm -rf $(LIBDIR)/why3/plugins
359
	mkdir -p $(LIBDIR)/why3/plugins
360
	cp -f $(foreach f,$(LIBPLUGCMO) $(LIBPLUGCMXS),$(wildcard $(f))) $(LIBDIR)/why3/plugins
361

362 363 364
######
# Why3
######
365

366 367
src/main.cmo: lib/why3/why3.cma
src/main.cmx: lib/why3/why3.cmxa
368

369 370
byte: bin/why3.byte
opt:  bin/why3.opt
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
371

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

376
bin/why3.byte: lib/why3/why3.cma src/main.cmo
377
	$(if $(QUIET),@echo 'Linking  $@' &&) \
378
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
379

380 381
bin/why3: bin/why3.@OCAMLBEST@
	ln -sf why3.@OCAMLBEST@ $@
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
382

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

386
install_local: bin/why3
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
387

388 389 390 391 392 393
ifneq "$(MAKECMDGOALS)" "clean"
include src/main.dep
endif

depend: src/main.dep

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
394
clean::
395 396
	rm -f src/main.cm[iox] src/main.annot src/main.o
	rm -f bin/why3.byte bin/why3.opt bin/why3
397
	rm -f bin/why3ml.byte bin/why3ml.opt bin/why3ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
398

399 400 401
##############
# test targets
##############
402

403 404
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
405

406 407
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
408

409 410
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
411

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

415
%.type: %.mlw bin/why3ide.opt
416
	bin/why3.opt --type-only $*.mlw
417

418 419 420 421
##########
# gallery
##########

422
# we export exactly the programs that have a why3session.xml file
423 424 425

.PHONY: gallery

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

MARCHE Claude's avatar
MARCHE Claude committed
440 441 442 443 444 445 446 447
########
# XML DTD validation
########

.PHONY: xml-validate

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

451 452 453 454
########
# Config
########

455
CONFIG_FILES = why3config
456

457
CONFIGMODULES = $(addprefix src/why3config/, $(CONFIG_FILES))
458

Andrei Paskevich's avatar
Andrei Paskevich committed
459
CONFIGDEP = $(addsuffix .dep, $(CONFIGMODULES))
460 461 462 463 464
CONFIGCMO = $(addsuffix .cmo, $(CONFIGMODULES))
CONFIGCMX = $(addsuffix .cmx, $(CONFIGMODULES))

# build targets

465 466
byte: bin/why3config.byte
opt:  bin/why3config.opt
467

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

472
bin/why3config.byte: lib/why3/why3.cma $(CONFIGCMO)
473
	$(if $(QUIET),@echo 'Linking  $@' &&) \
474
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
475

476 477 478
bin/why3config: bin/why3config.@OCAMLBEST@
	ln -sf why3config.@OCAMLBEST@ $@

479 480
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
481 482 483
ifneq "$(MAKECMDGOALS)" "clean"
include $(CONFIGDEP)
endif
484

Andrei Paskevich's avatar
Andrei Paskevich committed
485
depend: $(CONFIGDEP)
486 487

clean::
488 489 490
	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
491
	rm -f bin/why3config.byte bin/why3config.opt bin/why3config
492

493 494
local_config: bin/why3config.@OCAMLBEST@
	WHY3LIB=$(PWD) WHY3DATA=$(PWD)/share bin/why3config.@OCAMLBEST@ \
495
		--detect --conf_file why.conf
496

497
install_no_local::
498
	cp -f bin/why3config.@OCAMLBEST@ $(BINDIR)/why3config$(EXE)
499

500
install_local: bin/why3config
501

MARCHE Claude's avatar
MARCHE Claude committed
502 503 504 505
###############
# IDE
###############

506 507
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
508
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
509 510 511

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

Andrei Paskevich's avatar
Andrei Paskevich committed
512
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
513 514 515
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

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

519
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
520

521 522
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
523

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

527
bin/why3ide.opt: lib/why3/why3.cmxa $(IDECMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
528
	$(if $(QUIET),@echo 'Linking  $@' &&) \
529
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
MARCHE Claude's avatar
MARCHE Claude committed
530

531
bin/why3ide.byte: lib/why3/why3.cma $(IDECMO)
MARCHE Claude's avatar
MARCHE Claude committed
532
	$(if $(QUIET),@echo 'Linking  $@' &&) \
533
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
MARCHE Claude's avatar
MARCHE Claude committed
534

535 536 537
bin/why3ide: bin/why3ide.@OCAMLBEST@
	ln -sf why3ide.@OCAMLBEST@ $@

MARCHE Claude's avatar
MARCHE Claude committed
538 539
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
540 541 542
ifneq "$(MAKECMDGOALS)" "clean"
include $(IDEDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
543

Andrei Paskevich's avatar
Andrei Paskevich committed
544
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
545 546

clean::
547
	rm -f src/ide/xml.ml
MARCHE Claude's avatar
MARCHE Claude committed
548
	rm -f src/ide/*.cm[iox] src/ide/*.o
Andrei Paskevich's avatar
Andrei Paskevich committed
549
	rm -f src/ide/*.annot src/ide/*.dep src/ide/*~
550
	rm -f bin/why3ide.byte bin/why3ide.opt bin/why3ide
MARCHE Claude's avatar
MARCHE Claude committed
551

552
install_no_local::
553
	cp -f bin/why3ide.@OCAMLBEST@ $(BINDIR)/why3ide$(EXE)
554 555

install_local: bin/why3ide
556

557
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
558

559

MARCHE Claude's avatar
MARCHE Claude committed
560 561 562 563
###############
# Replayer
###############

François Bobot's avatar
François Bobot committed
564
REPLAYER_FILES = replay
MARCHE Claude's avatar
MARCHE Claude committed
565 566 567

REPLAYERMODULES = $(addprefix src/ide/, $(REPLAYER_FILES))

Andrei Paskevich's avatar
Andrei Paskevich committed
568
REPLAYERDEP = $(addsuffix .dep, $(REPLAYERMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
569 570 571
REPLAYERCMO = $(addsuffix .cmo, $(REPLAYERMODULES))
REPLAYERCMX = $(addsuffix .cmx, $(REPLAYERMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
572
$(REPLAYERDEP): DEPFLAGS += -I src/ide
Andrei Paskevich's avatar
Andrei Paskevich committed
573
$(REPLAYERCMO) $(REPLAYERCMX): INCLUDES += -I src/ide
MARCHE Claude's avatar
MARCHE Claude committed
574 575 576 577 578 579

# build targets

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

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

584
bin/why3replayer.byte: lib/why3/why3.cma $(REPLAYERCMO)
MARCHE Claude's avatar
MARCHE Claude committed
585
	$(if $(QUIET),@echo 'Linking  $@' &&) \
586
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
MARCHE Claude's avatar
MARCHE Claude committed
587 588 589 590 591 592

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

# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
593 594 595
ifneq "$(MAKECMDGOALS)" "clean"
include $(REPLAYERDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
596

Andrei Paskevich's avatar
Andrei Paskevich committed
597
depend: $(REPLAYERDEP)
MARCHE Claude's avatar
MARCHE Claude committed
598 599 600 601 602

clean::
	rm -f bin/why3replayer.byte bin/why3replayer.opt bin/why3replayer

install_no_local::
603
	cp -f bin/why3replayer.@OCAMLBEST@ $(BINDIR)/why3replayer$(EXE)
MARCHE Claude's avatar
MARCHE Claude committed
604 605 606

install_local: bin/why3replayer

607 608 609 610 611

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

612 613
SESSION_FILES = why3session_lib why3session_copy why3session_info	\
		why3session_latex why3session_html why3session_rm	\
614 615
		why3session_output why3session_run why3session_csv	\
		why3session
616 617 618

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

Andrei Paskevich's avatar
Andrei Paskevich committed
619
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
620 621 622
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
623
$(SESSIONDEP): DEPFLAGS += -I src/why3session
624 625 626 627 628 629 630
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

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

635
bin/why3session.byte: lib/why3/why3.cma $(SESSIONCMO)
636
	$(if $(QUIET),@echo 'Linking  $@' &&) \
637
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
638 639 640 641 642 643

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

# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
644 645 646
ifneq "$(MAKECMDGOALS)" "clean"
include $(SESSIONDEP)
endif
647

Andrei Paskevich's avatar
Andrei Paskevich committed
648
depend: $(SESSIONDEP)
649 650

clean::
Andrei Paskevich's avatar
Andrei Paskevich committed
651 652
	rm -f src/why3session/*.cm[iox] src/why3session/*.o
	rm -f src/why3session/*.annot src/why3session/*.dep src/why3session/*~
653 654 655 656 657 658 659
	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
660

661
###############
662
# Bench
663 664
###############

665 666
ifeq (@enable_bench@,yes)

667
BENCH_FILES = worker db bench benchrc benchdb why3bench
668

669
BENCHMODULES := $(addprefix src/why3bench/, $(BENCH_FILES))
670

Andrei Paskevich's avatar
Andrei Paskevich committed
671
BENCHDEP = $(addsuffix .dep, $(BENCHMODULES))
672 673 674
BENCHCMO = $(addsuffix .cmo, $(BENCHMODULES))
BENCHCMX = $(addsuffix .cmx, $(BENCHMODULES))

675 676
$(BENCHDEP): DEPFLAGS += -I src/why3bench
$(BENCHCMO) $(BENCHCMX): INCLUDES += -I src/why3bench -I @SQLITE3LIB@
677 678 679

# build targets

680 681
byte: bin/why3bench.byte
opt:  bin/why3bench.opt
682

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

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

690
bin/why3bench.byte: lib/why3/why3.cma $(BENCHCMO)
691
	$(if $(QUIET),@echo 'Linking  $@' &&) \
692
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
693

694 695 696
bin/why3bench: bin/why3bench.@OCAMLBEST@
	ln -sf why3bench.@OCAMLBEST@ $@

697 698
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
699 700 701
ifneq "$(MAKECMDGOALS)" "clean"
include $(BENCHDEP)
endif
702

Andrei Paskevich's avatar
Andrei Paskevich committed
703
depend: $(BENCHDEP)
704 705

clean::
706 707
	rm -f src/why3bench/*.cm[iox] src/why3bench/*.o
	rm -f src/why3bench/*.annot src/why3bench/*.dep src/why3bench/*~
708
	rm -f bin/why3bench.byte bin/why3bench.opt bin/why3bench
709 710

install_no_local::
711
	cp -f bin/why3bench.@OCAMLBEST@ $(BINDIR)/why3bench$(EXE)
712 713

install_local: bin/why3bench
714

715 716
endif

717 718 719
##############
# Coq plugin
##############
720

Andrei Paskevich's avatar
Andrei Paskevich committed
721
ifeq (@enable_coq_tactic@,yes)
722

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

Claude Marche's avatar
Claude Marche committed
725
COQP_FILES = coqCompat why3tac g_why3tac
726

727
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
728

729 730 731
COQPDEP = $(addsuffix .dep, $(COQPMODULES))
COQPCMO = $(addsuffix .cmo, $(COQPMODULES))
COQPCMX = $(addsuffix .cmx, $(COQPMODULES))
732

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

736
$(COQPDEP): DEPFLAGS += -I src/coq-tactic
737
$(COQPCMO) $(COQPCMX): INCLUDES += $(COQPINCLUDES)
Andrei Paskevich's avatar
Andrei Paskevich committed
738 739
$(COQPCMO) $(COQPCMX): BFLAGS += -rectypes
$(COQPCMX): OFLAGS += -rectypes
740

741
$(COQPDEP): $(COQPGENERATED)
742

743 744
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
745

Andrei Paskevich's avatar
Andrei Paskevich committed
746 747
src/coq-tactic/coqCompat.ml: src/coq-tactic/coqCompat@coq_compat_version@.ml
	cp -f $< $@
748

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

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

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

761
src/coq-tactic/.why3-vo-byte: lib/coq-tactic/Why3.v lib/coq-tactic/why3tac.cma
Andrei Paskevich's avatar
Andrei Paskevich committed
762
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
763
	    WHY3CONFIG="" $(COQC) -byte -I lib/coq-tactic/ $< && \
764
	    touch src/coq-tactic/.why3-vo-byte
765

766
src/coq-tactic/.why3-vo-opt: lib/coq-tactic/Why3.v lib/coq-tactic/why3tac.cmxs
Andrei Paskevich's avatar
Andrei Paskevich committed
767
	$(if $(QUIET),@echo 'Coqc     $<' &&) \
768
	    WHY3CONFIG="" $(COQC) -opt -I lib/coq-tactic/ $< && \
769
	    touch src/coq-tactic/.why3-vo-opt
770

771 772 773 774 775 776
test-coq-tactic.byte: src/coq-tactic/.why3-vo-byte
	$(COQC) -byte -I lib/coq-tactic/ src/coq-tactic/test.v

test-coq-tactic.opt: src/coq-tactic/.why3-vo-opt
	$(COQC) -opt -I lib/coq-tactic/ src/coq-tactic/test.v

777
# depend and clean targets
Andrei Paskevich's avatar
Andrei Paskevich committed
778

Andrei Paskevich's avatar
Andrei Paskevich committed
779
ifneq "$(MAKECMDGOALS)" "clean"
780
include $(COQPDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
781
endif
782

783
depend: $(COQPDEP)
784 785

clean::
786 787 788 789 790
	rm -f src/coq-tactic/*.cm[iox] src/coq-tactic/*.o
	rm -f lib/coq-tactic/*.cma lib/coq-tactic/*.cmxs
	rm -f lib/coq-tactic/*.vo lib/coq-tactic/*.glob
	rm -f src/coq-tactic/*.annot src/coq-tactic/*.dep src/coq-tactic/*~
	rm -f src/coq-tactic/.why3-vo-*
791
	rm -f $(COQPGENERATED)
792

793
install_no_local::
794 795
	mkdir -p $(LIBDIR)/why3/coq-tactic
	cp -f lib/coq-tactic/* $(LIBDIR)/why3/coq-tactic
796

797 798 799 800 801 802 803 804
endif

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

ifeq (@enable_coq_libs@,yes)

805
COQLIBS_INT_FILES = Abs ComputerDivision Div2 EuclideanDivision Int MinMax Power
806 807
COQLIBS_INT_ALL_FILES = Exponentiation $(COQLIBS_INT_FILES)
COQLIBS_INT = $(addprefix lib/coq/int/, $(COQLIBS_INT_ALL_FILES))
808

809
COQLIBS_REAL_FILES = Abs ExpLog FromInt MinMax PowerInt Real Square RealInfix
810 811
COQLIBS_REAL = $(addprefix lib/coq/real/, $(COQLIBS_REAL_FILES))

812
COQLIBS_NUMBER_FILES = Divisibility Gcd Parity Prime
813 814
COQLIBS_NUMBER = $(addprefix lib/coq/number/, $(COQLIBS_NUMBER_FILES))

815 816 817