Makefile.in 47.9 KB
Newer Older
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
1 2
##########################################################################
#                                                                        #
MARCHE Claude's avatar
MARCHE Claude committed
3
#  Copyright (C) 2010-2012                                               #
4 5 6
#    François Bobot                                                      #
#    Jean-Christophe Filliâtre                                           #
#    Claude Marché                                                       #
MARCHE Claude's avatar
MARCHE Claude committed
7
#    Guillaume Melquiond                                                 #
Jean-Christophe Filliâtre's avatar
headers  
Jean-Christophe Filliâtre committed
8
#    Andrei Paskevich                                                    #
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
9 10 11
#                                                                        #
#  This software is free software; you can redistribute it and/or        #
#  modify it under the terms of the GNU Library General Public           #
Jean-Christophe Filliâtre's avatar
headers  
Jean-Christophe Filliâtre committed
12
#  License version 2.1, with the special exception on linking            #
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
13 14 15 16 17 18 19 20
#  described in file LICENSE.                                            #
#                                                                        #
#  This software is distributed in the hope that it will be useful,      #
#  but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  #
#                                                                        #
##########################################################################

Andrei Paskevich's avatar
Andrei Paskevich committed
21
include Version
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
22

23 24 25 26 27 28
VERBOSEMAKE ?= @enable_verbose_make@

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

31
# install the binaries
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
32
DESTDIR =
33

34
prefix	    = @prefix@
35 36 37 38 39
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@

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

Andrei Paskevich's avatar
Andrei Paskevich committed
43
# OS specific stuff
44
EXE   = @EXE@
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
45 46

# other variables
47
CC        = @CC@
48 49 50 51 52 53 54 55 56
OCAMLC    = @OCAMLC@
OCAMLOPT  = @OCAMLOPT@
OCAMLDEP  = @OCAMLDEP@
OCAMLLEX  = @OCAMLLEX@
OCAMLYACC = @OCAMLYACC@
OCAMLDOC  = @OCAMLDOC@
OCAMLLIB  = @OCAMLLIB@
OCAMLBEST = @OCAMLBEST@
OCAMLVERSION = @OCAMLVERSION@
57 58
COQC      = @COQC@
COQDEP    = @COQDEP@
59 60
CAMLP5O   = @CAMLP5O@

Andrei Paskevich's avatar
Andrei Paskevich committed
61
DEPFLAGS  = -slash -I src
62
ifeq (@OCAMLBEST@,opt)
Andrei Paskevich's avatar
Andrei Paskevich committed
63
DEPFLAGS += -native
64 65
endif

66
RUBBER = @RUBBER@
67
HEVEA = @HEVEA@
68
HACHA = @HACHA@
69

70
#PSVIEWER  = @PSVIEWER@
Andrei Paskevich's avatar
Andrei Paskevich committed
71
#PDFVIEWER = @PDFVIEWER@
72

73
OFLAGS = -w Aer-29 -dtypes    -I src $(INCLUDES)
74 75 76 77
BFLAGS = -w Aer-29 -dtypes -g -I src $(INCLUDES)

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

79 80
LIBOPT =

Andrei Paskevich's avatar
Andrei Paskevich committed
81 82 83 84
ifeq (@enable_debug@,yes)
OFLAGS += -g
endif

85
ifeq (@enable_profiling@,yes)
86 87 88
OFLAGS += -g -p
endif

89 90
# external libraries common to all binaries

91
EXTOBJS =
Andrei Paskevich's avatar
Andrei Paskevich committed
92
EXTLIBS = str unix nums dynlink
93 94 95

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
96

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
97 98 99
###############
# main target
###############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
100

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

106 107 108 109 110
ifeq (@enable_local@,yes)
all: install_local
endif

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

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
113
#############
114
# Why library
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
115
#############
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
116

117
LIBGENERATED = src/util/rc.ml src/parser/lexer.ml \
118 119
	       src/parser/parser.mli src/parser/parser.ml \
	       src/driver/driver_parser.mli src/driver/driver_parser.ml \
120
	       src/driver/driver_lexer.ml src/session/xml.ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
121

Andrei Paskevich's avatar
Andrei Paskevich committed
122
LIB_UTIL = stdlib exn_printer pp debug loc print_tree \
123
	   cmdline hashweak hashcons util warning sysutil rc plugin
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
124

125
LIB_CORE = ident ty term pattern decl theory task pretty env trans printer
126

127
LIB_PARSER = ptree denv glob parser typing lexer
128

129
LIB_DRIVER = call_provers driver_ast driver_parser driver_lexer driver \
130
	     whyconf autodetection
131

132
LIB_TRANSFORM = simplify_recursive_definition simplify_formula \
Leon Gondelman's avatar
Leon Gondelman committed
133
		inlining split_goal induction \
134
		eliminate_definition eliminate_algebraic \
135
		eliminate_inductive eliminate_let eliminate_if \
136
		libencoding discriminate protect_finite \
137
		encoding encoding_select \
138
		encoding_decorate encoding_decoexp encoding_twin \
François Bobot's avatar
François Bobot committed
139
		encoding_explicit encoding_guard encoding_sort \
140
		encoding_instantiate simplify_array filter_trigger \
141
		introduction abstraction close_epsilon lift_epsilon \
142
		eval_match instantiate_predicate smoke_detector
143

Andrei Paskevich's avatar
Andrei Paskevich committed
144 145
LIB_PRINTER = print_number alt_ergo why3printer smtv1 smtv2 coq pvs \
		simplify gappa cvc3 yices
146

François Bobot's avatar
François Bobot committed
147 148
LIB_SESSION = xml termcode session session_tools session_scheduler

149
LIBMODULES = src/config \
150 151 152 153 154
	      $(addprefix src/util/, $(LIB_UTIL)) \
	      $(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
155 156
	      $(addprefix src/printer/, $(LIB_PRINTER)) \
	      $(addprefix src/session/, $(LIB_SESSION))
157

François Bobot's avatar
François Bobot committed
158
LIBDIRS = util core parser driver transform printer session
159
LIBINCLUDES = $(addprefix -I src/, $(LIBDIRS))
MARCHE Claude's avatar
MARCHE Claude committed
160

Andrei Paskevich's avatar
Andrei Paskevich committed
161
LIBDEP = $(addsuffix .dep, $(LIBMODULES))
162 163
LIBCMO = $(addsuffix .cmo, $(LIBMODULES))
LIBCMX = $(addsuffix .cmx, $(LIBMODULES))
164

Andrei Paskevich's avatar
Andrei Paskevich committed
165
$(LIBDEP): DEPFLAGS += $(LIBINCLUDES)
166
$(LIBCMO) $(LIBCMX): INCLUDES += $(LIBINCLUDES)
167
$(LIBCMX): OFLAGS += -for-pack Why3
168

169 170
$(LIBDEP): $(LIBGENERATED)

171
# build targets
172 173 174 175 176 177 178 179 180 181 182
LOCALOCAMLLIB=lib-ocaml
LOCALWHY3LIB=$(LOCALOCAMLLIB)/why3

byte:$(LOCALWHY3LIB)/why3.cma
opt:$(LOCALWHY3LIB)/why3.cmxa

$(LOCALWHY3LIB)/%.cma: src/%.cma
	@ln -sf ../../src/$*.cma $(LOCALWHY3LIB)
	@if test -f src/$*.cmi; then ln -sf ../../src/$*.cmi $(LOCALWHY3LIB); fi
	@if test -f src/$*.o; then ln -sf ../../src/$*.o $(LOCALWHY3LIB); fi

183

184 185 186 187 188 189 190
$(LOCALWHY3LIB)/%.cmxa: src/%.cmxa
	@ln -sf ../../src/$*.cmxa $(LOCALWHY3LIB)
	@if test -f src/$*.cmi; then ln -sf ../../src/$*.cmi $(LOCALWHY3LIB); fi
	@if test -f src/$*.a; then ln -sf ../../src/$*.a $(LOCALWHY3LIB); fi

clean::
	rm -f $(LOCALWHY3LIB)/why3*
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
191

192
src/why3.cma: src/why3.cmo
Andrei Paskevich's avatar
Andrei Paskevich committed
193 194
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) -a $(BFLAGS) -o $@ $^
195

196
src/why3.cmxa: src/why3.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
197 198
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) -a $(OFLAGS) -o $@ $^
199

200
src/why3.cmo: $(LIBCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
201 202
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
203

204
src/why3.cmx: $(LIBCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
205 206
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -pack -o $@ $^
207

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

Andrei Paskevich's avatar
Andrei Paskevich committed
210 211 212
ifneq "$(MAKECMDGOALS)" "clean"
include $(LIBDEP)
endif
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
213

214
depend: $(LIBDEP)
215

Andrei Paskevich's avatar
Andrei Paskevich committed
216
LIBSDIRS = src $(addprefix src/, $(LIBDIRS))
217 218
LIBCLEAN = $(addsuffix /*.cm[iox], $(LIBSDIRS)) \
	   $(addsuffix /*.annot, $(LIBSDIRS)) \
219 220
	   $(addsuffix /*.output, $(LIBSDIRS)) \
	   $(addsuffix /*.automaton, $(LIBSDIRS)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
221
	   $(addsuffix /*.dep, $(LIBSDIRS)) \
222 223 224 225 226
	   $(addsuffix /*.o, $(LIBSDIRS)) \
	   $(addsuffix /*~, $(LIBSDIRS))

clean::
	rm -f $(LIBCLEAN) $(LIBGENERATED)
227
	rm -f src/why3.cm[aiox] src/why3.[ao] src/why3.cmxa
228

229 230 231
###############
# installation
###############
232

MARCHE Claude's avatar
MARCHE Claude committed
233 234 235 236
clean_old_install:
	rm -f $(BINDIR)/why3*
	rm -rf $(DATADIR)/why3

237
install_no_local::
238
	mkdir -p $(BINDIR)
239
	mkdir -p $(DATADIR)/why3
240
	mkdir -p $(DATADIR)/why3/images
241 242
	mkdir -p $(DATADIR)/why3/images/boomy
	mkdir -p $(DATADIR)/why3/images/fatcow
MARCHE Claude's avatar
MARCHE Claude committed
243
	mkdir -p $(DATADIR)/why3/emacs
244
	mkdir -p $(DATADIR)/why3/lang
MARCHE Claude's avatar
MARCHE Claude committed
245
	mkdir -p $(DATADIR)/why3/theories
246
	mkdir -p $(DATADIR)/why3/modules
MARCHE Claude's avatar
MARCHE Claude committed
247 248
	mkdir -p $(DATADIR)/why3/drivers
	cp -f theories/*.why $(DATADIR)/why3/theories
249
	cp -f modules/*.mlw $(DATADIR)/why3/modules
Andrei Paskevich's avatar
Andrei Paskevich committed
250
	cp -f drivers/*.drv drivers/*.gen $(DATADIR)/why3/drivers
251
	cp -f share/provers-detection-data.conf $(DATADIR)/why3/
252
	cp -f share/images/icons.rc $(DATADIR)/why3/images
253
	cp -f share/images/*.png $(DATADIR)/why3/images
254 255
	cp -f share/images/boomy/*.png $(DATADIR)/why3/images/boomy
	cp -f share/images/fatcow/*.png $(DATADIR)/why3/images/fatcow
256
	cp -f share/why3session.dtd $(DATADIR)/why3
257
	cp -rf share/javascript $(DATADIR)/why3/javascript
MARCHE Claude's avatar
MARCHE Claude committed
258
	cp -f share/emacs/why.el $(DATADIR)/why3/emacs/why.el
259
	cp -f share/lang/why.lang $(DATADIR)/why3/lang/why.lang
260
#	if test -d /etc/bash_completion.d; then cp -f share/bash/why3 /etc/bash_completion.d; fi
261

MARCHE Claude's avatar
MARCHE Claude committed
262
install_no_local_lib::
263
	rm -rf $(OCAMLLIB)/why3
MARCHE Claude's avatar
MARCHE Claude committed
264
	mkdir -p $(OCAMLLIB)/why3
265 266 267
	cp -f -L $(LOCALWHY3LIB)/why3* $(OCAMLLIB)/why3
	cp -f $(LOCALWHY3LIB)/META $(OCAMLLIB)/why3

MARCHE Claude's avatar
MARCHE Claude committed
268

269 270 271 272 273
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
274
install: clean_old_install install_no_local
MARCHE Claude's avatar
MARCHE Claude committed
275
install-lib: install_no_local_lib
276 277
endif

MARCHE Claude's avatar
MARCHE Claude committed
278 279
install-all: install install-lib

280 281 282 283
##################
# Why plugins
##################

Andrei Paskevich's avatar
Andrei Paskevich committed
284 285
PLUGGENERATED = plugins/tptp/tptp_lexer.ml \
		plugins/tptp/tptp_parser.ml plugins/tptp/tptp_parser.mli
286 287

PLUG_PARSER = genequlin
288
PLUG_PRINTER =
289
PLUG_TRANSFORM =
290
PLUG_TPTP = tptp_ast tptp_parser tptp_typing tptp_lexer tptp_printer
291

292
PLUGINS = genequlin tptp
293

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

Andrei Paskevich's avatar
Andrei Paskevich committed
296 297
TPTPCMO = $(addsuffix .cmo, $(TPTPMODULES))
TPTPCMX = $(addsuffix .cmx, $(TPTPMODULES))
298

299 300 301 302 303 304 305 306 307 308
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

309 310
PLUGMODULES = $(addprefix plugins/parser/, $(PLUG_PARSER)) \
	      $(addprefix plugins/printer/, $(PLUG_PRINTER)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
311
	      $(addprefix plugins/transform/, $(PLUG_TRANSFORM)) \
Andrei Paskevich's avatar
Andrei Paskevich committed
312
	      $(TPTPMODULES)
313

Andrei Paskevich's avatar
Andrei Paskevich committed
314
PLUGDEP = $(addsuffix .dep, $(PLUGMODULES))
315 316 317
PLUGCMO = $(addsuffix .cmo, $(PLUGMODULES))
PLUGCMX = $(addsuffix .cmx, $(PLUGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
318
PLUGDIRS = parser printer transform tptp
319 320
PLUGINCLUDES = $(addprefix -I plugins/, $(PLUGDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
321
$(PLUGDEP): DEPFLAGS += $(PLUGINCLUDES)
322 323
$(PLUGCMO) $(PLUGCMX): INCLUDES += $(PLUGINCLUDES)

324 325
$(PLUGDEP): $(PLUGGENERATED)

326 327 328 329 330
LIBPLUGCMO =  $(addsuffix .cmo,  $(addprefix lib/plugins/, $(PLUGINS)))
LIBPLUGCMXS = $(addsuffix .cmxs, $(addprefix lib/plugins/, $(PLUGINS)))

plugins.byte: $(LIBPLUGCMO)
plugins.opt : $(LIBPLUGCMXS)
331 332

lib/plugins/%.cmxs: plugins/parser/%.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
333
	$(if $(QUIET),@echo 'Linking  $@' &&) \
334 335 336 337 338 339 340
	    $(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
341
	$(if $(QUIET),@echo 'Linking  $@' &&) \
342 343 344 345 346 347 348
	    $(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
349
	$(if $(QUIET),@echo 'Linking  $@' &&) \
350 351 352 353 354 355
	    $(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
356
lib/plugins/tptp.cmxs: $(TPTPCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
357
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
358
	    $(OCAMLOPT) $(OFLAGS) -shared -o $@ $^
359

Andrei Paskevich's avatar
Andrei Paskevich committed
360
lib/plugins/tptp.cmo: $(TPTPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
361
	$(if $(QUIET),@echo 'Linking  $@' &&) \
Andrei Paskevich's avatar
Andrei Paskevich committed
362
	    $(OCAMLC) $(BFLAGS) -pack -o $@ $^
363 364 365 366 367 368

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
369
	    $(addsuffix /*.dep, $(PLUGSDIRS)) \
370 371 372
	    $(addsuffix /*.o, $(PLUGSDIRS)) \
	    $(addsuffix /*~, $(PLUGSDIRS))

Andrei Paskevich's avatar
Andrei Paskevich committed
373 374 375 376 377 378
# depend and clean targets

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

379
depend: $(PLUGDEP)
Andrei Paskevich's avatar
Andrei Paskevich committed
380

381 382 383 384 385
clean::
	rm -f $(PLUGCLEAN) $(PLUGGENERATED)
	rm -f lib/plugins/*

install_no_local::
386
	rm -rf $(LIBDIR)/why3/plugins
387
	mkdir -p $(LIBDIR)/why3/plugins
388
	cp -f $(foreach f,$(LIBPLUGCMO) $(LIBPLUGCMXS),$(wildcard $(f))) $(LIBDIR)/why3/plugins
389

390

391 392 393
########
# Whyml (old API)
########
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
394

395
PGM_FILES = pgm_ttree pgm_types pgm_pretty \
396
	    pgm_module pgm_wp pgm_typing pgm_main
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
397

398
PGMMODULES = $(addprefix src/programs/, $(PGM_FILES))
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
399

400 401 402
PGMDEP = $(addsuffix .dep, $(PGMMODULES))
PGMCMO = $(addsuffix .cmo, $(PGMMODULES))
PGMCMX = $(addsuffix .cmx, $(PGMMODULES))
403

404 405
$(PGMDEP): DEPFLAGS += -I src/programs
$(PGMCMO) $(PGMCMX): INCLUDES += -I src/programs
406

407
# depend and clean targets
408

409 410 411
ifneq "$(MAKECMDGOALS)" "clean"
include $(PGMDEP)
endif
412

413
depend: $(PGMDEP)
414

415 416 417
clean::
	rm -f src/programs/*.cm[iox] src/programs/*.o
	rm -f src/programs/*.annot src/programs/*.dep src/programs/*~
418

419 420 421 422
########
# Whyml (new API)
########

423
MLW_FILES = mlw_ty mlw_expr mlw_decl mlw_pretty mlw_wp mlw_module \
424
	    mlw_dtree mlw_dty mlw_typing mlw_driver mlw_ocaml mlw_main
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446

MLWMODULES = $(addprefix src/whyml/, $(MLW_FILES))

MLWDEP = $(addsuffix .dep, $(MLWMODULES))
MLWCMO = $(addsuffix .cmo, $(MLWMODULES))
MLWCMX = $(addsuffix .cmx, $(MLWMODULES))

$(MLWDEP): DEPFLAGS += -I src/whyml
$(MLWCMO) $(MLWCMX): INCLUDES += -I src/whyml

# depend and clean targets

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

depend: $(MLWDEP)

clean::
	rm -f src/whyml/*.cm[iox] src/whyml/*.o
	rm -f src/whyml/*.annot src/whyml/*.dep src/whyml/*~

447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
## Whyml Library ###
#Should we separate the program library and the why3ml format?
#One should use linkall (just the module that register whyml)
#The others don't have to

#Currently a pack is not done but the cmi are not distributed
#So you can only link with why3ml in order to have the format .mlw

src/why3ml.cma src/why3ml.cmxa: LIBOPT += -linkall
src/why3ml.cma: $(PGMCMO) $(MLWCMO)
src/why3ml.cmxa: $(PGMCMX) $(MLWCMX)

opt:$(LOCALWHY3LIB)/why3ml.cmxa
byte:$(LOCALWHY3LIB)/why3ml.cma

clean::
	rm -f src/why3ml.cm[ai] src/why3ml.[ao] src/why3ml.cmxa


466 467 468
######
# Why3
######
469

470 471
src/main.cmo: src/why3.cma
src/main.cmx: src/why3.cmxa
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
472

473 474 475
src/main.cmo src/main.cmx: INCLUDES += -I src/whyml
src/main.dep: DEPFLAGS += -I src/whyml

476 477
byte: bin/why3.byte
opt:  bin/why3.opt
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
478

479
bin/why3.opt: src/why3.cmxa $(PGMCMX) $(MLWCMX) src/main.cmx
Andrei Paskevich's avatar
Andrei Paskevich committed
480
	$(if $(QUIET),@echo 'Linking  $@' &&) \
481
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
482

483
bin/why3.byte: src/why3.cma $(PGMCMO) $(MLWCMO) src/main.cmo
484
	$(if $(QUIET),@echo 'Linking  $@' &&) \
485
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
486

487 488
bin/why3: bin/why3.@OCAMLBEST@
	ln -sf why3.@OCAMLBEST@ $@
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
489

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

493
install_local: bin/why3
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
494

495 496 497 498 499 500
ifneq "$(MAKECMDGOALS)" "clean"
include src/main.dep
endif

depend: src/main.dep

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
501
clean::
502 503
	rm -f src/main.cm[iox] src/main.annot src/main.o
	rm -f bin/why3.byte bin/why3.opt bin/why3
504
	rm -f bin/why3ml.byte bin/why3ml.opt bin/why3ml
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
505

506 507 508
##############
# test targets
##############
509

510 511
%.gui: %.why bin/why3ide.opt
	bin/why3ide.opt $*.why
512

513 514
%: %.mlw bin/why3.opt
	bin/why3.opt $*.mlw
515

516 517
%: %.why bin/why3.opt
	bin/why3.opt $*.why
François Bobot's avatar
François Bobot committed
518

519 520
%.gui: %.mlw bin/why3ide.opt
	bin/why3ide.opt $*.mlw
521

522
%.type: %.mlw bin/why3ide.opt
523
	bin/why3.opt --type-only $*.mlw
524

525 526 527 528
##########
# gallery
##########

529
# we export exactly the programs that have a why3session.xml file
530 531 532

.PHONY: gallery

533 534
gallery::
	@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
535 536 537
	@for x in `find examples/programs/ -name why3session.xml`; do \
	  d=`dirname $$x`; \
	  f=`basename $$d`; \
538 539 540
	  echo "exporting $$f"; \
	  mkdir -p $(GALLERYDIR)/$$f; \
	  cp examples/programs/$$f.mlw $(GALLERYDIR)/$$f/; \
541 542 543 544
	  rm -f $(GALLERYDIR)/$$f/$$f.zip; \
	  cd examples/programs/; \
	  zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f; \
	  cd ../..; \
545
	done
546

MARCHE Claude's avatar
MARCHE Claude committed
547 548 549 550 551 552 553 554
########
# XML DTD validation
########

.PHONY: xml-validate

xml-validate:
	@for x in `find examples/ -name why3session.xml`; do \
MARCHE Claude's avatar
MARCHE Claude committed
555 556
	  xmllint --noout --dtdvalid share/why3session.dtd \
			$$x 2>&1 | head -1; \
MARCHE Claude's avatar
MARCHE Claude committed
557 558
	done

559 560 561 562 563 564 565 566
########
# Config
########

CONFIG_FILES = whyconfig

CONFIGMODULES = $(addprefix src/config/, $(CONFIG_FILES))

Andrei Paskevich's avatar
Andrei Paskevich committed
567
CONFIGDEP = $(addsuffix .dep, $(CONFIGMODULES))
568 569 570
CONFIGCMO = $(addsuffix .cmo, $(CONFIGMODULES))
CONFIGCMX = $(addsuffix .cmx, $(CONFIGMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
571
$(CONFIGDEP): DEPFLAGS += -I src/programs
572 573 574 575
$(CONFIGCMO) $(CONFIGCMX): INCLUDES += -I src/programs

# build targets

576 577
byte: bin/why3config.byte
opt:  bin/why3config.opt
578

579
bin/why3config.opt: src/why3.cmxa $(CONFIGCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
580
	$(if $(QUIET),@echo 'Linking  $@' &&) \
581
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
582

583
bin/why3config.byte: src/why3.cma $(CONFIGCMO)
584
	$(if $(QUIET),@echo 'Linking  $@' &&) \
585
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
586

587 588 589
bin/why3config: bin/why3config.@OCAMLBEST@
	ln -sf why3config.@OCAMLBEST@ $@

590 591
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
592 593 594
ifneq "$(MAKECMDGOALS)" "clean"
include $(CONFIGDEP)
endif
595

Andrei Paskevich's avatar
Andrei Paskevich committed
596
depend: $(CONFIGDEP)
597 598 599

clean::
	rm -f src/config/*.cm[iox] src/config/*.o
Andrei Paskevich's avatar
Andrei Paskevich committed
600
	rm -f src/config/*.annot src/config/*.dep src/config/*~
601
	rm -f src/config/*.output src/config/*.automaton
602
	rm -f bin/why3config.byte bin/why3config.opt bin/why3config
603

604 605
local_config: bin/why3config.@OCAMLBEST@
	WHY3LIB=$(PWD) WHY3DATA=$(PWD)/share bin/why3config.@OCAMLBEST@ \
606
		--detect --conf_file why.conf
607

608
install_no_local::
609
	cp -f bin/why3config.@OCAMLBEST@ $(BINDIR)/why3config$(EXE)
610

611
install_local: bin/why3config
612

MARCHE Claude's avatar
MARCHE Claude committed
613 614 615 616
###############
# IDE
###############

617 618
ifeq (@enable_ide@,yes)

François Bobot's avatar
François Bobot committed
619
IDE_FILES = gconfig gmain
MARCHE Claude's avatar
MARCHE Claude committed
620 621 622

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

Andrei Paskevich's avatar
Andrei Paskevich committed
623
IDEDEP = $(addsuffix .dep, $(IDEMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
624 625 626
IDECMO = $(addsuffix .cmo, $(IDEMODULES))
IDECMX = $(addsuffix .cmx, $(IDEMODULES))

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

630
# build targets
MARCHE Claude's avatar
MARCHE Claude committed
631

632 633
byte: bin/why3ide.byte
opt:  bin/why3ide.opt
MARCHE Claude's avatar
MARCHE Claude committed
634

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

638
bin/why3ide.opt: src/why3.cmxa $(PGMCMX) $(MLWCMX) $(IDECMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
639
	$(if $(QUIET),@echo 'Linking  $@' &&) \
640
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
MARCHE Claude's avatar
MARCHE Claude committed
641

642
bin/why3ide.byte: src/why3.cma $(PGMCMO) $(MLWCMO) $(IDECMO)
MARCHE Claude's avatar
MARCHE Claude committed
643
	$(if $(QUIET),@echo 'Linking  $@' &&) \
644
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
MARCHE Claude's avatar
MARCHE Claude committed
645

646 647 648
bin/why3ide: bin/why3ide.@OCAMLBEST@
	ln -sf why3ide.@OCAMLBEST@ $@

MARCHE Claude's avatar
MARCHE Claude committed
649 650
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
651 652 653
ifneq "$(MAKECMDGOALS)" "clean"
include $(IDEDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
654

Andrei Paskevich's avatar
Andrei Paskevich committed
655
depend: $(IDEDEP)
MARCHE Claude's avatar
MARCHE Claude committed
656 657

clean::
658
	rm -f src/ide/xml.ml
MARCHE Claude's avatar
MARCHE Claude committed
659
	rm -f src/ide/*.cm[iox] src/ide/*.o
Andrei Paskevich's avatar
Andrei Paskevich committed
660
	rm -f src/ide/*.annot src/ide/*.dep src/ide/*~
661
	rm -f bin/why3ide.byte bin/why3ide.opt bin/why3ide
MARCHE Claude's avatar
MARCHE Claude committed
662

663
install_no_local::
664
	cp -f bin/why3ide.@OCAMLBEST@ $(BINDIR)/why3ide$(EXE)
665 666

install_local: bin/why3ide
667

668
endif
MARCHE Claude's avatar
d  
MARCHE Claude committed
669

670

MARCHE Claude's avatar
MARCHE Claude committed
671 672 673 674
###############
# Replayer
###############

François Bobot's avatar
François Bobot committed
675
REPLAYER_FILES = replay
MARCHE Claude's avatar
MARCHE Claude committed
676 677 678

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

Andrei Paskevich's avatar
Andrei Paskevich committed
679
REPLAYERDEP = $(addsuffix .dep, $(REPLAYERMODULES))
MARCHE Claude's avatar
MARCHE Claude committed
680 681 682
REPLAYERCMO = $(addsuffix .cmo, $(REPLAYERMODULES))
REPLAYERCMX = $(addsuffix .cmx, $(REPLAYERMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
683
$(REPLAYERDEP): DEPFLAGS += -I src/ide
Andrei Paskevich's avatar
Andrei Paskevich committed
684
$(REPLAYERCMO) $(REPLAYERCMX): INCLUDES += -I src/ide
MARCHE Claude's avatar
MARCHE Claude committed
685 686 687 688 689 690

# build targets

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

691
bin/why3replayer.opt: src/why3.cmxa $(PGMCMX) $(MLWCMX) $(REPLAYERCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
692
	$(if $(QUIET),@echo 'Linking  $@' &&) \
693
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
MARCHE Claude's avatar
MARCHE Claude committed
694

695
bin/why3replayer.byte: src/why3.cma $(PGMCMO) $(MLWCMO) $(REPLAYERCMO)
MARCHE Claude's avatar
MARCHE Claude committed
696
	$(if $(QUIET),@echo 'Linking  $@' &&) \
697
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
MARCHE Claude's avatar
MARCHE Claude committed
698 699 700 701 702 703

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

# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
704 705 706
ifneq "$(MAKECMDGOALS)" "clean"
include $(REPLAYERDEP)
endif
MARCHE Claude's avatar
MARCHE Claude committed
707

Andrei Paskevich's avatar
Andrei Paskevich committed
708
depend: $(REPLAYERDEP)
MARCHE Claude's avatar
MARCHE Claude committed
709 710 711 712 713

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

install_no_local::
714
	cp -f bin/why3replayer.@OCAMLBEST@ $(BINDIR)/why3replayer$(EXE)
MARCHE Claude's avatar
MARCHE Claude committed
715 716 717

install_local: bin/why3replayer

718 719 720 721 722

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

723
SESSION_FILES = why3session_lib why3session_copy why3session_info \
724 725
		why3session_latex why3session_html why3session_rm \
		why3session
726 727 728

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

Andrei Paskevich's avatar
Andrei Paskevich committed
729
SESSIONDEP = $(addsuffix .dep, $(SESSIONMODULES))
730 731 732
SESSIONCMO = $(addsuffix .cmo, $(SESSIONMODULES))
SESSIONCMX = $(addsuffix .cmx, $(SESSIONMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
733
$(SESSIONDEP): DEPFLAGS += -I src/why3session
734 735 736 737 738 739 740
$(SESSIONCMO) $(SESSIONCMX): INCLUDES += -I src/why3session

# build targets

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

741
bin/why3session.opt: src/why3.cmxa $(PGMCMX) $(MLWCMX) $(SESSIONCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
742
	$(if $(QUIET),@echo 'Linking  $@' &&) \
743
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
744

745
bin/why3session.byte: src/why3.cma $(PGMCMO) $(MLWCMO) $(SESSIONCMO)
746
	$(if $(QUIET),@echo 'Linking  $@' &&) \
747
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
748 749 750 751 752 753

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

# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
754 755 756
ifneq "$(MAKECMDGOALS)" "clean"
include $(SESSIONDEP)
endif
757

Andrei Paskevich's avatar
Andrei Paskevich committed
758
depend: $(SESSIONDEP)
759 760

clean::
Andrei Paskevich's avatar
Andrei Paskevich committed
761 762
	rm -f src/why3session/*.cm[iox] src/why3session/*.o
	rm -f src/why3session/*.annot src/why3session/*.dep src/why3session/*~
763 764 765 766 767 768 769
	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
770

771
###############
772
# Bench
773 774
###############

775 776
ifeq (@enable_bench@,yes)

777
BENCH_FILES = worker db bench benchrc benchdb whybench
778 779 780

BENCHMODULES := $(addprefix src/bench/, $(BENCH_FILES))

Andrei Paskevich's avatar
Andrei Paskevich committed
781
BENCHDEP = $(addsuffix .dep, $(BENCHMODULES))
782 783 784
BENCHCMO = $(addsuffix .cmo, $(BENCHMODULES))
BENCHCMX = $(addsuffix .cmx, $(BENCHMODULES))

Andrei Paskevich's avatar
Andrei Paskevich committed
785
$(BENCHDEP): DEPFLAGS += -I src/bench
786
$(BENCHCMO) $(BENCHCMX): INCLUDES += -I src/bench -I @SQLITE3LIB@
787 788 789

# build targets

790 791
byte: bin/why3bench.byte
opt:  bin/why3bench.opt
792

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

796
bin/why3bench.opt: src/why3.cmxa $(PGMCMX) $(MLWCMX) $(BENCHCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
797
	$(if $(QUIET),@echo 'Linking  $@' &&) \
798
	    $(OCAMLOPT) $(OFLAGS) -o $@ $(OLINKFLAGS) $^
799

800
bin/why3bench.byte: src/why3.cma  $(PGMCMO) $(MLWCMO) $(BENCHCMO)
801
	$(if $(QUIET),@echo 'Linking  $@' &&) \
802
	    $(OCAMLC) $(BFLAGS) -o $@ $(BLINKFLAGS) $^
803

804 805 806
bin/why3bench: bin/why3bench.@OCAMLBEST@
	ln -sf why3bench.@OCAMLBEST@ $@

807 808
# depend and clean targets

Andrei Paskevich's avatar
Andrei Paskevich committed
809 810 811
ifneq "$(MAKECMDGOALS)" "clean"
include $(BENCHDEP)
endif
812

Andrei Paskevich's avatar
Andrei Paskevich committed
813
depend: $(BENCHDEP)
814 815 816

clean::
	rm -f src/bench/*.cm[iox] src/bench/*.o
Andrei Paskevich's avatar
Andrei Paskevich committed
817
	rm -f src/bench/*.annot src/bench/*.dep src/bench/*~
818
	rm -f bin/why3bench.byte bin/why3bench.opt bin/why3bench
819 820

install_no_local::
821
	cp -f bin/why3bench.@OCAMLBEST@ $(BINDIR)/why3bench$(EXE)
822 823

install_local: bin/why3bench
824

825 826
endif

827 828 829
##############
# Coq plugin
##############
830

Andrei Paskevich's avatar
Andrei Paskevich committed
831
ifeq (@enable_coq_tactic@,yes)
832

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

Claude Marche's avatar
Claude Marche committed
835
COQP_FILES = coqCompat why3tac g_why3tac
836

837
COQPMODULES = $(addprefix src/coq-tactic/, $(COQP_FILES))
838

839 840 841
COQPDEP = $(addsuffix .dep, $(COQPMODULES))
COQPCMO = $(addsuffix .cmo, $(COQPMODULES))
COQPCMX = $(addsuffix .cmx, $(COQPMODULES))
842

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

846
$(COQPDEP): DEPFLAGS += -I src/coq-tactic
847
$(COQPCMO) $(COQPCMX): INCLUDES += $(COQPINCLUDES)
Andrei Paskevich's avatar
Andrei Paskevich committed
848 849
$(COQPCMO) $(COQPCMX): BFLAGS += -rectypes
$(COQPCMX): OFLAGS += -rectypes
850

851
$(COQPDEP): $(COQPGENERATED)
852

853 854
byte: src/coq-tactic/.why3-vo-byte
opt:  src/coq-tactic/.why3-vo-opt
855

Andrei Paskevich's avatar
Andrei Paskevich committed
856 857
src/coq-tactic/coqCompat.ml: src/coq-tactic/coqCompat@coq_compat_version@.ml
	cp -f $< $@
858

859
lib/coq-tactic/why3tac.cmxs: src/why3.cmxa $(COQPCMX)
Andrei Paskevich's avatar
Andrei Paskevich committed
860 861
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLOPT) $(OFLAGS) -o $@ -shared $^
862

863
lib/coq-tactic/why3tac.cma: src/why3.cma $(COQPCMO)
Andrei Paskevich's avatar
Andrei Paskevich committed
864 865
	$(if $(QUIET),@echo 'Linking  $@' &&) \
	    $(OCAMLC) -a $(BFLAGS) -o $@ $^
866