Makefile.in 39.1 KB
Newer Older
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
1 2
##########################################################################
#                                                                        #
Jean-Christophe Filliâtre's avatar
headers  
Jean-Christophe Filliâtre committed
3 4
#  Copyright (C) Francois Bobot, Jean-Christophe Filliatre,              #
#  Johannes Kanig and Andrei Paskevich.                                  #
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
5 6 7
#                                                                        #
#  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
8
#  License version 2.1, with the special exception on linking            #
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
#  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.                  #
#                                                                        #
##########################################################################

VERBOSEMAKE ?= @VERBOSEMAKE@

ifeq ($(VERBOSEMAKE),yes)
 QUIET = 
else    
 QUIET = yes
endif

# where to install the binaries
DESTDIR =
prefix=@prefix@
datarootdir=@datarootdir@
exec_prefix=@exec_prefix@
BINDIR=$(DESTDIR)@bindir@
LIBDIR=$(DESTDIR)@libdir@

EXE=@EXE@
STRIP=@STRIP@

# where to install the man page
MANDIR=$(DESTDIR)@mandir@

# other variables
OCAMLC   = @OCAMLC@ 
OCAMLOPT = @OCAMLOPT@ 
OCAMLDEP = @OCAMLDEP@
OCAMLLEX = @OCAMLLEX@
OCAMLYACC= @OCAMLYACC@
OCAMLDOC = @OCAMLDOC@
OCAMLLIB = @OCAMLLIB@
OCAMLBEST= @OCAMLBEST@
OCAMLVERSION = @OCAMLVERSION@
CAMLP4   = @CAMLP4O@

INCLUDES = -I src 
BFLAGS   = -w Aelz -dtypes -g $(INCLUDES) @INCLUDEGTK2@ -I +threads @OCAMLGRAPHLIB@ 
# no -warn-error because some do not compile all files (e.g. those linked to APRON)
OFLAGS   = -w Aelz -dtypes $(INCLUDES) @INCLUDEGTK2@ -I +threads @OCAMLGRAPHLIB@ 

LCFLAGS = -L/usr/lib -L/usr/local/lib/ocaml

APRONLIB = @APRONLIB@
APRONLIBS = @APRONLIBS@
APRONBYTLIBS = $(APRONLIBS:.cmxa=.cma)

FRAMAC= @FRAMAC@

ifeq ($(FRAMAC),yes)
JESSIE_PLUGIN_BYTE= jessie_plugin.byte
JESSIE_PLUGIN_OPT= jessie_plugin.opt
JESSIE_PLUGIN_BEST= jessie_plugin.$(OCAMLBEST)
.PHONY: $(JESSIE_PLUGIN_BYTE) $(JESSIE_PLUGIN_OPT)
endif

ATPLIB = -I atp

COQC7  = @COQC7@
COQC8  = @COQC8@
COQDEP = @COQDEP@
COQLIB = "@COQLIB@"
COQVER = @COQVER@

VO7= lib/coq-v7/WhyInt.vo lib/coq-v7/WhyArrays.vo  lib/coq-v7/WhyBool.vo \
     lib/coq-v7/WhyTuples.vo  lib/coq-v7/WhyPermut.vo \
     lib/coq-v7/WhySorted.vo  lib/coq-v7/Why.vo     lib/coq-v7/WhyReal.vo \
     lib/coq-v7/WhyExn.vo lib/coq-v7/WhyCoqCompat.vo \
     lib/coq-v7/WhyLemmas.vo  lib/coq-v7/WhyTactics.vo lib/coq-v7/WhyCM.vo 

V7FILES=$(VO7:.vo=.v)

VO8= lib/coq/WhyInt.vo lib/coq/WhyArrays.vo  lib/coq/WhyBool.vo \
     lib/coq/WhyTuples.vo  lib/coq/WhyPermut.vo lib/coq/WhyCoqCompat.vo \
     lib/coq/WhySorted.vo  \
     lib/coq/WhyExn.vo lib/coq/WhyLemmas.vo  lib/coq/WhyTactics.vo \
     lib/coq/WhyPrelude.vo lib/coq/WhyCM.vo lib/coq/Why.vo lib/coq/WhyReal.vo \
     @WHYFLOATS@ \
     lib/coq/caduceus_why.vo lib/coq/caduceus_tactics.vo \
     lib/coq/caduceus_lists.vo lib/coq/Caduceus.vo \
     @JESSIELIBCOQ@ 

V8FILES=$(VO8:.vo=.v)

PVSFILES = lib/pvs/why.pvs lib/pvs/jessie.pvs lib/pvs/whyfloat.pvs 
PVSLIB = @PVSLIB@

GENERATED = src/version.ml 
# src/rc.ml src/xml.ml \
# 	    src/lexer.ml src/parser.mli \
#             src/parser.ml src/linenum.ml \
#             jc/numconst.ml \
# 	    jc/jc_lexer.ml jc/jc_parser.mli jc/jc_parser.ml \
# 	    jc/jc_ai.ml \
# 	    java/java_parser.mli java/java_parser.ml java/java_lexer.ml \
# 	    ml/parsing/parser.mli ml/parsing/parser.ml ml/parsing/lexer.ml \
# 	    ml/parsing/linenum.ml \
# 	    c/cversion.ml c/clexer.ml c/cparser.ml c/cparser.mli \
# 	    c/cllexer.ml c/clparser.ml c/clparser.mli c/cpp.ml c/cconst.ml \
# 	    intf/hilight.ml intf/whyhilight.ml \
# 	    intf/tagsplit.ml intf/config.ml \
# 	    tools/why2html.ml  tools/cvcl_split.ml \
# 	    tools/simplify_split.ml tools/smtlib_split.ml tools/rv_split.ml \
# 	    tools/zenon_split.ml tools/ergo_split.ml \
# 	    tools/simplify_lexer.ml tools/simplify_parser.mli \
# 	    tools/simplify_parser.ml \
# 	    tools/toolstat_lex.ml \
# 	    tools/toolstat_pars.ml tools/toolstat_pars.mli \
# 	    mix/mix_lexer.ml mix/mix_parser.mli mix/mix_parser.ml 


# main targets
##############

BINARY=bin/why.$(OCAMLBEST)
WHYCONFIG=bin/why-config.$(OCAMLBEST)
CADUCEUS=bin/caduceus.$(OCAMLBEST)
JESSIE=bin/jessie.$(OCAMLBEST)
KRAKATOA=bin/krakatoa.$(OCAMLBEST)
JESSICA=bin/jessica.$(OCAMLBEST)
STATICBINARY=bin/why.static
WHY2HTML=bin/why2html.$(OCAMLBEST)
RVMERGE=bin/rv_merge.$(OCAMLBEST)
DP=bin/why-dp.$(OCAMLBEST)
CPULIMIT=bin/why-cpulimit
WHYOBFUSCATOR=bin/why-obfuscator.$(OCAMLBEST)
WHYSTAT=bin/why-stat.$(OCAMLBEST)
TOOLSTAT=bin/tool-stat.$(OCAMLBEST)
SIMPLIFY2WHY=bin/simplify2why.$(OCAMLBEST)
REGTEST=regtest.$(OCAMLBEST)

TOOLS=$(WHY2HTML) $(DP) $(CPULIMIT) $(RVMERGE) $(WHYOBFUSCATOR) \
      $(SIMPLIFY2WHY) $(WHYSTAT) $(TOOLSTAT)

ifeq ($(OCAMLBEST),opt)
JCLIB=jc/jc.cmo jc/jc.cmx jc/jc.o
else
JCLIB=jc/jc.cmo
endif

all: .depend $(BINARY) $(WHYCONFIG) check $(CADUCEUS) $(JESSIE) $(KRAKATOA) coq-@COQ@ pvs-@PVS@ $(TOOLS) gwhy-@LABLGTK2@ $(JCLIB) $(REGTEST) $(JESSIE_PLUGIN_BEST)

# refrain parallel make (-j nn) from starting ocaml compilation too early 
*.cm*: .depend

opt: bin/why.opt bin/gwhy.opt bin/caduceus.opt bin/jessie.opt bin/krakatoa.opt \
	$(JESSIE_PLUGIN_OPT)
byte: bin/why.byte bin/gwhy.byte bin/caduceus.byte bin/jessie.byte bin/krakatoa.byte \
	$(JESSIE_PLUGIN_BYTE)

.PHONY: check

WHYLIBS=lib/why/bool.why lib/why/integer.why \
	lib/why/real.why lib/why/arrays.why lib/why/floats.why \
	lib/why/floats_common.why lib/why/floats_strict.why lib/why/floats_multi_rounding.why\
	lib/why/floats_full.why \
	lib/why/jessie.why lib/why/mybag.why \
	lib/why/mix.why \
	lib/why/double_model.why lib/why/double_strict.why lib/why/single_model.why lib/why/single_strict.why

GENERATEDCOQFILES=floats_common_Floats floats_common_Gappa

PRELUDE=lib/why/prelude.why $(WHYLIBS)

# sanity check: the prelude files do typecheck
check: $(BINARY) $(PRELUDE)
	WHYLIB=lib $(BINARY) --no-pervasives -tc lib/why/prelude.why
	for f in $(WHYLIBS) ; do \
		WHYLIB=lib $(BINARY) -tc $$f; \
	done

generate_coq_files: $(BINARY) 
	for f in $(GENERATEDCOQFILES) ; do \
		WHYLIB=lib $(BINARY) -output lib/coq/$$f lib/why/floats_common.why ;\
	done

lib/coq/float_common_Gappa_why.v: lib/why/floats_common.why
	WHYLIB=lib $(BINARY) -tc -output $@ $< 

# why-config
WHYCONFIGCMO = src/rc.cmo src/version.cmo tools/dpConfig.cmo tools/whyConfig.cmo
WHYCONFIGCMX = $(WHYCONFIGCMO:.cmo=.cmx)

bin/why-config.opt: $(WHYCONFIGCMX)
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLOPT) $(OFLAGS) -o $@ unix.cmxa str.cmxa $^
	$(STRIP) $@

bin/why-config.byte: $(WHYCONFIGCMO)
	# $(if $(QUIET),@echo 'Linking  $@' &&) 
	$(OCAMLC) $(BFLAGS) -o $@ unix.cma str.cma $^


# why
CMO_EXPORT =  src/lib.cmo src/rc.cmo src/loc.cmo \
	   src/ident.cmo src/print_real.cmo  \
	   src/effect.cmo src/pp.cmo src/option_misc.cmo src/misc.cmo 	\
	   src/parser.cmo src/lexer.cmo src/report.cmo \
           src/env.cmo src/rename.cmo src/explain.cmo 	\
	   src/xml.cmo src/project.cmo 

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
215
CMO = src/name.cmo src/hashcons.cmo src/term.cmo
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
216 217
CMX      = $(CMO:.cmo=.cmx)

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
218
bin/why.opt: $(CMX) 
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
219 220 221
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLOPT) $(OFLAGS) -o $@ unix.cmxa str.cmxa nums.cmxa graph.cmxa $^
	$(STRIP) $@

Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
222
bin/why.byte: $(CMO) 
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLC) $(BFLAGS) -o $@ unix.cma str.cma nums.cma graph.cma $^

bin/why.static: $(CMX) src/why.cmx 
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLOPT) -cclib -static $(OFLAGS) -o $@ unix.cmxa str.cmxa nums.cmxa graph.cmxa $^ 
	$(STRIP) $@

bin/top: $(CMO)
	ocamlmktop $(BFLAGS) -o $@ str.cma $^

# world-why-web
WWEBCMO = src/lib.cmo src/rc.cmo src/version.cmo src/options.cmo src/loc.cmo\
	 src/ident.cmo  src/effect.cmo src/pp.cmo \
	src/option_misc.cmo\
	src/misc.cmo src/parser.cmo src/lexer.cmo src/report.cmo\
	 src/env.cmo src/rename.cmo src/explain.cmo src/util.cmo src/xml.cmo\
	src/project.cmo src/pretty.cmo src/wserver.cmo src/whyweb.cmo
WWEBCMX = $(WWEBCMO:.cmo=.cmx)

src/wserver.ml: src/wserver.ml4
	camlp4r pa_ifdef.cmo pr_o.cmo -DUNIX -DNOFORK  -impl $^ -o $@

bin/whyweb.opt: $(WWEBCMX) 
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLOPT) \
	      $(OFLAGS) -thread -o $@ str.cmxa unix.cmxa threads.cmxa $^
	$(STRIP)    $@

# caduceus
CCMO = src/lib.cmo src/linenum.cmo \
	src/loc.cmo src/pp.cmo src/option_misc.cmo \
	src/version.cmo jc/output.cmo \
	c/cversion.cmo c/coptions.cmo c/cutil.cmo \
	c/ctypes.cmo c/info.cmo c/creport.cmo c/cconst.cmo \
	c/cenv.cmo c/cltyping.cmo c/ctyping.cmo c/cprint_graph.cmo \
	c/cgraph.cmo c/cinit.cmo \
	c/cast_misc.cmo c/clparser.cmo c/cllexer.cmo \
	c/cparser.cmo c/clexer.cmo \
	c/cprint.cmo c/cnorm.cmo  c/cseparation.cmo \
	c/invariant.cmo c/ceffect.cmo \
	c/cinterp.cmo c/cpp.cmo c/cmake.cmo c/cabsint.cmo c/cptr.cmo \
	c/csymbol.cmo c/cmain.cmo 
CCMA = 
CCMX = $(CCMO:.cmo=.cmx)
CCMXA = $(CCMA:.cma=.cmxa)

bin/caduceus.opt: $(CCMXA) $(CCMX) 
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLOPT) \
	      $(OFLAGS) -o $@ unix.cmxa str.cmxa graph.cmxa $^
	$(STRIP)    $@

bin/caduceus.byte: $(CCMA) $(CCMO) 
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLC) \
	      $(BFLAGS) -o $@ unix.cma str.cma graph.cma $^

bin/caduceus.static: $(CCMXA) $(CCMX) 
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLOPT) -cclib -static $(OFLAGS) -o $@ unix.cmxa str.cmxa graph.cmxa $^

	$(STRIP)    $@


# jessie
JCCML_EXPORT = jc/output.ml \
	jc/jc_common_options.ml jc/jc_stdlib.ml \
	jc/jc_envset.ml jc/jc_region.ml jc/jc_fenv.ml \
	jc/jc_constructors.ml \
	jc/jc_pervasives.ml jc/jc_iterators.ml jc/jc_type_var.ml \
	jc/jc_output_misc.ml jc/jc_poutput.ml jc/jc_output.ml jc/jc_noutput.ml
JCCMO_EXPORT = $(CMO_EXPORT) $(JCCML_EXPORT:.ml=.cmo)
JCCMX_EXPORT = $(JCCMO_EXPORT:.cmo=.cmx)
JCCMI_EXPORT = jc/jc_ast.cmi jc/jc_env.cmi jc/jc.cmi $(JCCMO_EXPORT:.cmo=.cmi)

JCCMO = src/version.cmo \
	@ATPCMO@ $(JCCMO_EXPORT) \
	jc/jc_options.cmo \
	jc/jc_name.cmo \
	jc/jc_struct_tools.cmo \
	jc/jc_norm.cmo jc/jc_typing.cmo \
	jc/numconst.cmo \
	jc/jc_parser.cmo jc/jc_lexer.cmo \
	jc/jc_separation.cmo \
	jc/jc_callgraph.cmo \
	jc/jc_effect.cmo \
	jc/jc_ai.cmo \
	jc/jc_interp_misc.cmo jc/jc_invariants.cmo \
	jc/jc_pattern.cmo \
	jc/jc_interp.cmo \
	jc/jc_frame.cmo \
	jc/jc_make.cmo jc/jc_main.cmo
JCCMX = $(JCCMO:.cmo=.cmx)

$(JCCMX_EXPORT): OFLAGS:=$(OFLAGS) -for-pack Jc

atp/atp.cmx: 
	make -C atp atp.cmx

atp/atp.cmo: 
	make -C atp atp.cmo

jc/jc.cmi jc/jc.cmo: $(JCCMO_EXPORT)
	$(OCAMLC) $(BFLAGS) -pack -o jc/jc.cmo src/ast.cmi $^

jc/jc.cmx: $(JCCMX_EXPORT)
	$(OCAMLOPT) $(OFLAGS) -pack -o $@ src/ast.cmi $^

ppc: jc/jc.cmi jc/jc.cmo jc/jc.cmx

bin/jessie.opt: $(JCCMX)
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLOPT) $(OFLAGS) $(APRONLIB) $(APRONLIBS) $(ATPLIB) -o $@ \
		unix.cmxa str.cmxa nums.cmxa graph.cmxa $^
	$(STRIP)    $@

bin/jessie.byte: $(JCCMO) 
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLC) $(BFLAGS) $(APRONLIB) $(APRONBYTLIBS) $(ATPLIB) -o $@ \
		unix.cma str.cma nums.cma graph.cma $^


# Frama-C plugin for Jessie
# ifeq ($(FRAMAC),yes)
# JESSIE_PLUGIN_PATH=frama-c-plugin
# $(JESSIE_PLUGIN_BYTE): jc/jc.cmo $(JCCMO) $(CMO)
# 	$(MAKE) -C $(JESSIE_PLUGIN_PATH) depend
# 	$(MAKE) -C $(JESSIE_PLUGIN_PATH) Jessie.cmo

# $(JESSIE_PLUGIN_OPT): $(JCLIB) $(JCCMX) $(CMX)
# 	$(MAKE) -C $(JESSIE_PLUGIN_PATH) depend
# 	$(MAKE) -C $(JESSIE_PLUGIN_PATH)

# install: 
# 	$(MAKE) -C $(JESSIE_PLUGIN_PATH) install
# clean::
# 	$(MAKE) -C $(JESSIE_PLUGIN_PATH) clean
# endif

# krakatoa
# CAUTION! NEVER ADD jc/jc_options.cmo INTO THIS LIST
KCMO = src/lib.cmo src/version.cmo \
	src/loc.cmo src/pp.cmo src/option_misc.cmo \
	jc/output.cmo jc/jc_stdlib.cmo \
	jc/jc_envset.cmo jc/jc_common_options.cmo \
	jc/jc_region.cmo jc/jc_fenv.cmo jc/numconst.cmo jc/jc_constructors.cmo \
	jc/jc_pervasives.cmo jc/jc_name.cmo \
	jc/jc_iterators.cmo jc/jc_type_var.cmo jc/jc_output_misc.cmo \
	jc/jc_poutput.cmo jc/jc_output.cmo jc/jc_noutput.cmo jc/output.cmo \
	java/java_options.cmo java/java_pervasives.cmo \
	java/java_abstract.cmo \
	java/java_parser.cmo java/java_lexer.cmo java/java_syntax.cmo \
	java/java_typing.cmo java/java_callgraph.cmo \
	java/java_analysis.cmo java/java_interp.cmo \
	java/java_main.cmo
KCMX = $(KCMO:.cmo=.cmx)

bin/krakatoa.opt: $(KCMX) 
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLOPT) $(OFLAGS) -o $@ \
		unix.cmxa nums.cmxa graph.cmxa $^
	$(STRIP)    $@

bin/krakatoa.byte: $(KCMO) 
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLC) $(BFLAGS) -o $@ \
	 	 unix.cma nums.cma graph.cma $^


# jessica

JESSICACMO = ml/ml_misc.cmo ml/ml_options.cmo ml/ml_pervasives.cmo \
	ml/ml_env.cmo ml/ml_constant.cmo ml/ml_type.cmo ml/ml_pattern.cmo \
	ml/ml_interp.cmo ml/ml_main.cmo
JESSICACMI = ml/ml_options.cmi ml/ml_env.cmi ml/ml_pattern.cmi

JESSICACMX = $(JESSICACMO:.cmo=.cmx)
MLCMO = src/loc.cmo src/pp.cmo src/option_misc.cmo jc/jc_stdlib.cmo \
	jc/jc_envset.cmo jc/jc_common_options.cmo \
	jc/jc_region.cmo jc/jc_fenv.cmo jc/numconst.cmo jc/jc_constructors.cmo \
	jc/jc_pervasives.cmo jc/jc_name.cmo \
	jc/jc_iterators.cmo jc/jc_output_misc.cmo \
	jc/jc_poutput.cmo jc/jc_output.cmo jc/jc_noutput.cmo \
	$(JESSICACMO)
MLCMX = $(MLCMO:.cmo=.cmx)

# The following files must be compiled with different includes and with the
# -for-pack option
OCAMLCMO = ml/utils/config.cmo ml/utils/clflags.cmo \
	ml/utils/misc.cmo ml/utils/terminfo.cmo ml/utils/warnings.cmo \
	ml/utils/consistbl.cmo ml/utils/tbl.cmo \
	ml/parsing/linenum.cmo ml/parsing/location.cmo \
	ml/parsing/syntaxerr.cmo \
	ml/parsing/longident.cmo ml/parsing/parser.cmo ml/parsing/lexer.cmo \
	ml/typing/ident.cmo ml/typing/path.cmo ml/typing/types.cmo \
	ml/typing/oprint.cmo ml/typing/btype.cmo ml/typing/predef.cmo \
	ml/typing/datarepr.cmo ml/typing/subst.cmo ml/typing/env.cmo \
	ml/typing/primitive.cmo ml/typing/ctype.cmo ml/typing/printtyp.cmo \
	ml/typing/includeclass.cmo ml/typing/parmatch.cmo \
	ml/typing/stypes.cmo ml/typing/typedtree.cmo \
	ml/typing/includecore.cmo ml/typing/typetexp.cmo ml/typing/mtype.cmo \
	ml/typing/typedecl.cmo ml/typing/unused_var.cmo \
	ml/typing/typecore.cmo ml/typing/typeclass.cmo \
	ml/typing/includemod.cmo ml/typing/typemod.cmo
OCAMLCMINOIMPL = ml/parsing/asttypes.cmi ml/parsing/parsetree.cmi \
	ml/typing/outcometree.cmi
OCAMLCMI = $(OCAMLCMINOIMPL) ml/utils/config.cmi ml/utils/clflags.cmi \
	ml/utils/misc.cmi ml/utils/terminfo.cmi ml/utils/warnings.cmi \
	ml/utils/consistbl.cmi ml/utils/tbl.cmi \
	ml/parsing/linenum.cmi ml/parsing/location.cmi ml/parsing/parser.cmi \
	ml/parsing/lexer.cmi ml/parsing/longident.cmi ml/parsing/syntaxerr.cmi \
	ml/typing/btype.cmi ml/typing/ctype.cmi ml/typing/datarepr.cmi \
	ml/typing/env.cmi ml/typing/ident.cmi ml/typing/includeclass.cmi \
	ml/typing/includecore.cmi ml/typing/includemod.cmi ml/typing/mtype.cmi \
	ml/typing/oprint.cmi ml/typing/parmatch.cmi \
	ml/typing/path.cmi ml/typing/predef.cmi ml/typing/primitive.cmi \
	ml/typing/printtyp.cmi ml/typing/stypes.cmi ml/typing/subst.cmi \
	ml/typing/typeclass.cmi ml/typing/typecore.cmi ml/typing/typedecl.cmi \
	ml/typing/typedtree.cmi ml/typing/typemod.cmi ml/typing/types.cmi \
	ml/typing/typetexp.cmi ml/typing/unused_var.cmi
OCAMLCMX = $(OCAMLCMO:.cmo=.cmx)

MLINCLUDES = #-I ml/utils -I ml/parsing -I ml/typing

# The following dependencies are not found by ocamldep because there is no
# file ml/ml_ocaml.ml or ml/ml_ocaml.mli.
$(JESSICACMO): ml/ml_ocaml.cmo
$(JESSICACMX): ml/ml_ocaml.cmx
$(JESSICACMI): ml/ml_ocaml.cmo

ml/parsing/%.cmi: ml/parsing/%.mli
	$(if $(QUIET),@echo 'Ocamlc   $@' &&) \
		$(OCAMLC) -c $(MLINCLUDES) -for-pack Ml_ocaml ml/parsing/$*.mli

ml/parsing/%.cmx: ml/parsing/%.ml
	$(if $(QUIET),@echo 'Ocamlopt $@' &&) \
		$(OCAMLOPT) -c $(MLINCLUDES) -for-pack Ml_ocaml ml/parsing/$*.ml

ml/parsing/%.cmo: ml/parsing/%.ml
	$(if $(QUIET),@echo 'Ocamlc   $@' &&) \
		$(OCAMLC) -c $(MLINCLUDES) -for-pack Ml_ocaml ml/parsing/$*.ml

ml/typing/%.cmi: ml/typing/%.mli
	$(if $(QUIET),@echo 'Ocamlc   $@' &&) \
		$(OCAMLC) -c $(MLINCLUDES) -for-pack Ml_ocaml ml/typing/$*.mli

ml/typing/%.cmx: ml/typing/%.ml
	$(if $(QUIET),@echo 'Ocamlopt $@' &&) \
		$(OCAMLOPT) -c $(MLINCLUDES) -for-pack Ml_ocaml ml/typing/$*.ml

ml/typing/%.cmo: ml/typing/%.ml
	$(if $(QUIET),@echo 'Ocamlc   $@' &&) \
		$(OCAMLC) -c $(MLINCLUDES) -for-pack Ml_ocaml ml/typing/$*.ml

ml/utils/%.cmi: ml/utils/%.mli
	$(if $(QUIET),@echo 'Ocamlc   $@' &&) \
		$(OCAMLC) -c $(MLINCLUDES) -for-pack Ml_ocaml ml/utils/$*.mli

ml/utils/%.cmx: ml/utils/%.ml
	$(if $(QUIET),@echo 'Ocamlopt $@' &&) \
		$(OCAMLOPT) -c $(MLINCLUDES) -for-pack Ml_ocaml ml/utils/$*.ml

ml/utils/%.cmo: ml/utils/%.ml
	$(if $(QUIET),@echo 'Ocamlc   $@' &&) \
		$(OCAMLC) -c $(MLINCLUDES) -for-pack Ml_ocaml ml/utils/$*.ml

ml/ml_ocaml.cmx: $(OCAMLCMINOIMPL) $(OCAMLCMX)
	$(if $(QUIET),@echo 'Ocamlopt $@' &&) \
		$(OCAMLOPT) -c $(MLINCLUDES) -pack -o $@ $^

ml/ml_ocaml.cmo: $(OCAMLCMINOIMPL) $(OCAMLCMO)
	$(if $(QUIET),@echo 'Ocamlc   $@' &&) \
		$(OCAMLC) -c $(MLINCLUDES) -pack -o $@ $^

bin/jessica.opt: ml/ml_ocaml.cmx $(MLCMX)
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLOPT) $(OFLAGS) -o $@ \
		unix.cmxa nums.cmxa graph.cmxa $^
	$(STRIP)    $@

bin/jessica.byte: ml/ml_ocaml.cmo $(MLCMO)
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLC) $(BFLAGS) -o $@ \
	 	 unix.cma nums.cma graph.cma $^


# demixify

MIXCMO=src/pp.cmo mix/mix_parser.cmo mix/mix_lexer.cmo mix/mix_cfg.cmo \
       mix/mix_seq.cmo mix/mix_interp.cmo mix/mix_main.cmo
MIXCMX = $(MIXCMO:.cmo=.cmx)

bin/demixify.opt: $(MIXCMX)
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLOPT) $(OFLAGS) -o $@ $^
	$(STRIP)    $@

bin/demixify.byte: $(MIXCMO)
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLC) $(BFLAGS) -o $@ $^

# graphical interface
WVCMO = $(CMO) intf/navig.cmo intf/hilight.cmo intf/viewer.cmo
WVCMX = $(WVCMO:.cmo=.cmx)

bin/why-viewer.opt: $(WVCMX)
	$(OCAMLOPT) $(OFLAGS) -o $@ unix.cmxa gramlib.cmxa str.cmxa lablgtk.cmxa $^
	$(STRIP) $@

bin/why-viewer.byte: $(WVCMO)
	$(OCAMLC) $(BFLAGS) -o $@ unix.cma gramlib.cma str.cma lablgtk.cma $^

# graphical interface
GCMO = $(CMO) intf/colors.cmo intf/tags.cmo intf/tools.cmo intf/tagsplit.cmo\
	      intf/astprinter.cmo intf/astnprinter.cmo intf/astpprinter.cmo\
	      intf/model.cmo intf/cache.cmo intf/gConfig.cmo intf/hilight.cmo\
	      intf/whyhilight.cmo intf/pprinter.cmo intf/preferences.cmo intf/stat.cmo
GCMX = $(GCMO:.cmo=.cmx)

gwhy-yes: bin/gwhy.$(OCAMLBEST)
gwhy-no:
gwhy: bin/gwhy.$(OCAMLBEST)

bin/gwhy.opt: $(GCMX)
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLOPT) $(OFLAGS) -o $@ unix.cmxa threads.cmxa nums.cmxa str.cmxa graph.cmxa lablgtk.cmxa gtkThread.cmx $^
	$(STRIP)    $@

bin/gwhy.static: $(GCMX)
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLOPT) -cclib -static $(OFLAGS) -o $@ unix.cmxa threads.cmxa nums.cmxa str.cmxa graph.cmxa lablgtk.cmxa gtkThread.cmx $^
	$(STRIP)    $@

bin/gwhy.byte: $(GCMO)
	$(if $(QUIET),@echo 'Linking  $@' &&) $(OCAMLC) $(BFLAGS) -o $@ unix.cma str.cma nums.cma graph.cma lablgtk.cma threads.cma gtkThread.cmo $^

# tools
regtest.opt: tools/regtest.ml
	$(OCAMLOPT) $(OFLAGS) -thread -o $@ unix.cmxa str.cmxa threads.cmxa $^

regtest.byte: tools/regtest.ml
	$(OCAMLC) $(BFLAGS) -thread -o $@ unix.cma str.cma threads.cma $^

bin/why2html.byte: tools/why2html.ml
	$(OCAMLC) $(BFLAGS) -o $@ $^

bin/why2html.opt: tools/why2html.ml
	$(OCAMLOPT) $(OFLAGS) -o $@ $^

SIMPLIFYTOWHYCMO=src/ident.cmo src/pp.cmo \
                 tools/simplify_parser.cmo tools/simplify_lexer.cmo \
                 tools/simplify_towhy.cmo
SIMPLIFYTOWHYCMX = $(SIMPLIFYTOWHYCMO:.cmo=.cmx)

bin/simplify2why.byte: $(SIMPLIFYTOWHYCMO)
	$(OCAMLC) $(BFLAGS) -o $@ $^

bin/simplify2why.opt: $(SIMPLIFYTOWHYCMX)
	$(OCAMLOPT) $(OFLAGS) -o $@ $^

DPCMO = tools/cvcl_split.cmo tools/simplify_split.cmo tools/smtlib_split.cmo\
        tools/zenon_split.cmo tools/ergo_split.cmo tools/rv_split.cmo \
        src/rc.cmo tools/dpConfig.cmo src/version.cmo \
	tools/calldp.cmo tools/dp.cmo
DPCMX = $(DPCMO:.cmo=.cmx)

bin/why-dp.byte: $(DPCMO)
	$(OCAMLC) $(BFLAGS) -o $@ unix.cma str.cma $^

bin/why-dp.opt: $(DPCMX)
	$(OCAMLOPT) $(OFLAGS) -o $@ unix.cmxa str.cmxa $^

bin/why-cpulimit: tools/@CPULIMIT@.c
	$(CC) -o $@ $^

bin/rv_merge.byte: tools/rv_merge.ml
	$(OCAMLC) $(BFLAGS) -o $@ $^

bin/rv_merge.opt: tools/rv_merge.ml
	$(OCAMLOPT) $(OFLAGS) -o $@ $^

OBFCMO=src/pp.cmo src/loc.cmo src/ident.cmo  \
       src/parser.cmo src/lexer.cmo src/print_real.cmo tools/obfuscator.cmo
OBFCMX=$(OBFCMO:.cmo=.cmx)

bin/why-obfuscator.byte: $(OBFCMO)
	$(OCAMLC) $(BFLAGS) -o $@ nums.cma $^

bin/why-obfuscator.opt: $(OBFCMX)
	$(OCAMLOPT) $(OFLAGS) -o $@ nums.cmxa $^

STATCMO=src/pp.cmo src/loc.cmo src/ident.cmo  \
        src/parser.cmo src/lexer.cmo tools/whystat.cmo
STATCMX=$(STATCMO:.cmo=.cmx)

bin/why-stat.byte: $(STATCMO)
	$(OCAMLC) $(BFLAGS) -o $@ $^

bin/why-stat.opt: $(STATCMX)
	$(OCAMLOPT) $(OFLAGS) -o $@ $^

TOOLCMO=src/loc.cmo src/pp.cmo tools/toolstat_pars.cmo \
	tools/toolstat_lex.cmo tools/toolstat.cmo
TOOLCMX=$(TOOLCMO:.cmo=.cmx)

bin/tool-stat.byte: $(TOOLCMO)
	$(OCAMLC) $(BFLAGS) -o $@ $^

bin/tool-stat.opt: $(TOOLCMX)
	$(OCAMLOPT) $(OFLAGS) -o $@ $^

bin/cadlog.opt: src/version.cmx tools/cadlog.cmx
	$(OCAMLOPT) unix.cmxa -o $@ $^

tools/make_float_model.opt: tools/make_float_model.cmx
	$(OCAMLOPT) -o $@ $^

lib/why/double_model.why lib/why/double_strict.why: tools/make_float_model.opt
	tools/make_float_model.opt double 53 -1074 

lib/why/single_model.why lib/why/single_strict.why: tools/make_float_model.opt
	tools/make_float_model.opt single 24 -149 


static:: $(STATICBINARY)

########
# COQ
########

coq-no:
coq-yes: coq-@COQVER@
coq-v7: $(VO7)
coq-v8: generate_coq_files $(VO8)
coq-v8.1: generate_coq_files $(VO8)

########
# PVS
########

pvs-no:
pvs-yes: $(PVSFILES)

include Version

doc/version.tex src/version.ml c/cversion.ml: Version version.sh config.status
	BINDIR=$(BINDIR) LIBDIR=$(LIBDIR) COQVER=$(COQVER) ./version.sh

lib/coq/caduceus_why.v: lib/why/caduceus.why $(BINARY)
	WHYLIB=lib $(BINARY) --dir lib/coq --coq-v8 lib/why/caduceus.why

lib/coq-v7/caduceus_why.v: lib/why/caduceus.why $(BINARY)
	WHYLIB=lib $(BINARY) --dir lib/coq-v7 --coq-v7 lib/why/caduceus.why

lib/coq/jessie_why.v: lib/why/jessie.why $(BINARY)
	WHYLIB=lib $(BINARY) --dir lib/coq --coq-v8 lib/why/jessie.why

lib/pvs/jessie_why.pvs: lib/why/jessie.why $(BINARY)
	WHYLIB=lib $(BINARY) --dir lib/pvs --pvs --pvs-preamble "IMPORTING why" lib/why/jessie.why

# bench

.PHONY: bench test

WHYVO=lib/coq/Why.vo

bench:: $(BINARY) $(WHYVO)
	cd bench; sh ./bench "../$(BINARY)"
	make -C bench fastwp.bench.ergo
	make -C examples ergo
	#cd bench/provers; sh ./bench "../../$(BINARY)"

JCBENCHLOG=jessie-bench-`date +%d-%m-%y`.log

# Claude: does not work anymore, because someone modified bench/jc/bench 
# GRRRRRRRRRRRR
# jc-bench:: $(JESSIE) bin/cadlog.opt
#	(cd bench/jc; sh ./bench 2>&1) | bin/cadlog.opt -jc $(JCBENCHLOG)

jc-fast-bench:: $(JESSIE)
	make -C bench/jc -f Makefile good.bench

JCAIBENCHLOG=jessie-ai-bench-`date +%d-%m-%y`.log

jc-ai-bench:: $(JESSIE) bin/cadlog.opt
	(cd bench/jc/ai; sh ./bench 2>&1) | bin/cadlog.opt -jc $(JCAIBENCHLOG)

JAVABENCHLOG=krakatoa-bench-`date +%d-%m-%y`.log

java-bench:: $(KRAKATOA) bin/cadlog.opt
	(cd bench/java; sh ./bench 2>&1) | bin/cadlog.opt -java $(JAVABENCHLOG)

ml-bench:: $(JESSICA) $(JESSIE)
	make -C bench/ml -f Makefile good.bench

BENCHLOG=bench-caduceus-`date +%d-%m-%y`.log

bench-c:: $(CADUCEUS) $(WHYVO) bin/cadlog.opt
	(cd bench/c; sh ./bench 2>&1) | bin/cadlog.opt $(BENCHLOG)
	(cd examples-c/linked-lists; make swap reverse)

bench-absint:: $(CADUCEUS) $(WHYVO) bin/cadlog.opt
	(cd bench/c/absint; sh ./bench 2>&1) | bin/cadlog.opt $(BENCHLOG)

bench-pvs:: $(BINARY) $(WHYVO)
	cd bench; sh ./bench "../$(BINARY) --valid" pvs

bench-tc:: $(BINARY) $(WHYVO)
	cd bench; sh ./bench "../$(BINARY) -tc"

test:: $(BINARY) $(WHYVO)
	$(BINARY) -d -V -coq bench/test.ml

.PHONY: examples examples-c

examples:: $(BINARY) $(WHYVO)
	make -C examples check

examples-c:: $(BINARY) $(CADUCEUS) $(WHYVO)
	make -C examples-c

# debugging

db debug: bin/why.byte src/logic.cmo

#src/logic.ml: src/logic.mli
#	cp -f $^ $@

# java APIs
#################

java_api:
	(cd lib/java_api ; for i in java/lang/*.java; do \
		mkdir -p `dirname ../distr_java_api/$$i` ; \
		echo "Generating $$i" ; \
		KRAKATOALIB=.. ../../$(KRAKATOA) -abstract ../distr_java_api/$$i $$i || break ; done)

# installation
##############

install: install-binary install-lib install-man install-coq-@COQ@ install-pvs-@PVS@ 

BINARYFILES = $(BINARY) $(WHYCONFIG) $(CADUCEUS) $(JESSIE) $(KRAKATOA) \
	$(WHY2HTML) $(DP) $(CPULIMIT) $(RVMERGE) bin/gwhy.$(OCAMLBEST) \
	$(WHYSTAT) $(TOOLSTAT) $(WHYOBFUSCATOR) $(SIMPLIFY2WHY)

# install-binary should not depend on $(BINARYFILES); otherwise it
# enforces the compilation of gwhy, even when lablgtk2 is not installed
install-binary: 
	mkdir -p $(BINDIR)
	cp -f $(BINARY) $(BINDIR)/why$(EXE)
	cp -f $(WHYCONFIG) $(BINDIR)/why-config$(EXE)
	cp -f $(CADUCEUS) $(BINDIR)/caduceus$(EXE)
	cp -f $(JESSIE) $(BINDIR)/jessie$(EXE)
	cp -f $(KRAKATOA) $(BINDIR)/krakatoa$(EXE)
	cp -f bin/gwhy.sh $(BINDIR)/gwhy
	cp -f $(WHY2HTML) $(BINDIR)/why2html$(EXE)
	cp -f $(DP) $(BINDIR)/why-dp$(EXE)
	cp -f $(CPULIMIT) $(BINDIR)/why-cpulimit$(EXE)
	cp -f $(RVMERGE) $(BINDIR)/rv_merge$(EXE)
	cp -f $(WHYOBFUSCATOR) $(BINDIR)/why-obfuscator$(EXE)
	cp -f $(WHYSTAT) $(BINDIR)/why-stat$(EXE)
	cp -f $(TOOLSTAT) $(BINDIR)/tool-stat$(EXE)
	cp -f $(SIMPLIFY2WHY) $(BINDIR)/simplify2why$(EXE)
	if test -f bin/gwhy.$(OCAMLBEST); then \
		cp -f bin/gwhy.$(OCAMLBEST) $(BINDIR)/gwhy-bin$(EXE); \
	fi

install-lib: $(JCLIB)
	mkdir -p $(LIBDIR)/why/why
	cp -f $(PRELUDE) $(LIBDIR)/why/why
	mkdir -p $(LIBDIR)/caduceus/why
	mkdir -p $(LIBDIR)/jessie
	cp -f $(JCLIB) $(JCCMI_EXPORT) $(LIBDIR)/jessie
	cp -f lib/why/caduceus.why $(LIBDIR)/caduceus/why
	cp -f lib/why/caduceus_arith.why $(LIBDIR)/caduceus/why
	mkdir -p $(LIBDIR)/caduceus/coq
	mkdir -p $(LIBDIR)/coq
	if test "@COQVER@" = "v7"; then \
	  cp -f lib/coq-v7/caduceus_why.v lib/coq-v7/caduceus_tactics.v $(LIBDIR)/caduceus/coq; \
	else \
	  cp -f lib/coq/caduceus_why.v lib/coq/caduceus_tactics.v $(LIBDIR)/caduceus/coq; \
	  cp -f lib/coq/jessie_why.v $(LIBDIR)/coq; \
	fi
	mkdir -p $(LIBDIR)/caduceus/isabelle
	cp -f lib/isabelle/caduceus_why.thy $(LIBDIR)/caduceus/isabelle
	mkdir -p $(LIBDIR)/caduceus/harvey
	cp -f lib/harvey/caduceus_why.rv $(LIBDIR)/caduceus/harvey
	cd lib; cp -r java_api $(LIBDIR)/why 
	cd lib; cp -r javacard_api $(LIBDIR)/why
	mkdir -p $(LIBDIR)/why/images
	cp -f lib/images/*.png $(LIBDIR)/why/images
#	remove CVS directories
	find $(LIBDIR) -name CVS | xargs $(RM) -r

install-man:
	mkdir -p $(MANDIR)/man1
	cp -f doc/*.1 $(MANDIR)/man1

install-coq-no:
install-coq-yes: install-coq-@COQVER@
install-coq-v7:
	mkdir -p $(LIBDIR)/why/coq7
	cp -f $(V7FILES) $(LIBDIR)/why/coq7
	cp -f $(VO7) $(LIBDIR)/why/coq7
install-coq-v8 install-coq-v8.1:
	if test -w $(COQLIB) ; then \
	 mkdir -p $(COQLIB)/user-contrib ; \
	 cp -f $(V8FILES) $(COQLIB)/user-contrib ; \
	 cp -f $(VO8) $(COQLIB)/user-contrib ; \
	else \
	echo "Cannot copy to Coq standard library. Add $(LIBDIR)/why/coq to Coq include path." ;\
	mkdir -p $(LIBDIR)/why/coq ;\
	cp -f $(VO8) $(V8FILES) $(LIBDIR)/why/coq ;\
	fi

install-pvs-no:
install-pvs-yes: $(PVSFILES)
	mkdir -p $(PVSLIB)/why
	cp $(PVSFILES) $(PVSFILES:.pvs=.prf) $(PVSLIB)/why
	cp lib/pvs/top.pvs lib/pvs/pvscontext.el $(PVSLIB)/why
	@echo "======  Compiling PVS theories, this may take some time ======"
	(cd $(PVSLIB)/why ; @PVSC@ -batch -l pvscontext.el -q -v 2 > top.out)
	@echo "======  Done compiling PVS theories ======"

install-mizar-no:
install-mizar-yes:
	mkdir -p @MIZARLIB@/mml/dict
	cp lib/mizar/why.miz @MIZARLIB@/mml
	cp lib/mizar/dict/why.voc @MIZARLIB@/mml/dict

local-install: $(BINARY) $(WHYCONFIG) $(CADUCEUS) $(JESSIE) bin/gwhy.$(OCAMLBEST) byte bin/gwhy.byte 
	cp $(BINARY) $$HOME/bin/why
	cp $(WHYCONFIG) $$HOME/bin/why
	cp $(CADUCEUS) $$HOME/bin/caduceus
	cp $(JESSIE) $$HOME/bin/jessie
	if test -f bin/gwhy.$(OCAMLBEST); then \
	  cp -f bin/gwhy.$(OCAMLBEST) $$HOME/bin/gwhy; \
	fi

local: install
# local: bin/why.opt $(CADUCEUS) $(WHY2HTML) $(DP) $(RVMERGE) coq-@COQ@
# 	cp -f bin/why.opt $$HOME/bin/$$OSTYPE/why
# 	cp -f $(CADUCEUS) $$HOME/bin/$$OSTYPE/caduceus
# 	cp -f $(WHY2HTML) $$HOME/bin/$$OSTYPE/why2html
# 	cp -f $(DP) $$HOME/bin/$$OSTYPE/dp
# 	cp -f $(RVMERGE) $$HOME/bin/$$OSTYPE/rv_merge
# #	mkdir -p $(COQLIB)/contrib7/why
# #	cp -f $(VO7) $(VFILES) $(COQLIB)/contrib7/why
# #	mkdir -p $(COQLIB)/contrib/why
# #	cp -f $(VO8) $(VFILES) $(COQLIB)/contrib/why
# 	mkdir -p $(PVSLIB)/why
# 	cp $(PVSFILES) $(PVSLIB)/why
# 	mkdir -p $(MIZFILES)/mml/dict
# 	cp lib/mizar/why.miz $(MIZFILES)/mml
# 	cp lib/mizar/dict/why.voc $(MIZFILES)/mml/dict
# 	mkdir -p $$HOME/man/man1
# 	cp -f doc/*.1 $$HOME/man/man1

demons: $(STATICBINARY) doc/manual.ps
	cp -f $(STATICBINARY) /users/demons/demons/bin/$$OSTYPE/why
	cp doc/manual.ps /users/demons/demons/docs/why.ps

win: why.nsi
	"/cygdrive/c/Program Files (x86)/NSIS/makensis" /DVERSION=$(VERSION) why.nsi

zip:
	zip -A -r why-$(VERSION).zip c:/why/bin c:/why/lib c:/coq/lib/contrib/why c:/coq/lib/contrib7/why

# doc

DOC=doc/manual.ps doc/manual.html doc/caduceus.ps doc/caduceus.html \
	doc/krakatoa.pdf doc/krakatoa.html \
	doc/main.pdf doc/main.html

doc:: $(DOC)


doc/manual.ps: doc/manual.tex doc/version.tex
	make -C doc manual.ps

# doc/version.tex: Version Makefile.in
#	echo '\newcommand{\whyversion}'"{$(VERSION)}" > $@
#	echo '\newcommand{\caduceusversion}'"{$(CVERSION)}" >> $@
#	echo '\newcommand{\jessieversion}'"{$(JCVERSION)}" >> $@
#	echo '\newcommand{\krakatoaversion}'"{$(KVERSION)}" >> $@

doc/manual.html: doc/manual.tex doc/version.tex
	make -C doc manual.html

doc/caduceus.ps: doc/caduceus.tex doc/version.tex
	make -C doc caduceus.ps

doc/caduceus.html: doc/caduceus.tex doc/version.tex
	make -C doc caduceus.html

doc/krakatoa.pdf: doc/krakatoa.tex doc/version.tex
	make -C doc krakatoa.pdf

doc/krakatoa.html: doc/krakatoa.tex doc/version.tex
	make -C doc krakatoa.html

doc/main.pdf: doc/main.tex doc/version.tex
	make -C doc main.pdf

doc/main.html: doc/main.tex doc/version.tex
	make -C doc main.html


# API HTML DOC
##############

OCAMLDOCSRC = intf/model.mli $(WHYCONFIGCMO:.cmo=.ml) $(WHYCONFIGCMI:.cmi=.mli)
	# $(JCCMO:.cmo=.ml) $(JCCMI:.cmi=.mli) 

apidoc: $(OCAMLDOCSRC)
	mkdir -p ocamldoc
	rm -f ocamldoc/* 
	$(OCAMLDOC) -d ocamldoc -html $(INCLUDES) @INCLUDEGTK2@ $(OCAMLDOCSRC)


# special rules
###############

# CAMLP4=@CAMLP4O@ pa_extend.cmo pa_macro.cmo

# src/%.cmo: src/%.ml4
# 	$(OCAMLC) -c $(BFLAGS) -pp "$(CAMLP4) -DOCAML@OCAMLV@ -impl" -impl $<

# src/%.cmx: src/%.ml4
# 	$(OCAMLOPT) -c $(OFLAGS) -pp "$(CAMLP4) -DOCAML@OCAMLV@ -impl" -impl $<

# src/%.ml: src/%.ml4
# 	$(CAMLP4) pr_o.cmo -DOCAML@OCAMLV@ -impl $< > $@

# generic rules
###############

.SUFFIXES: .mli .ml .cmi .cmo .cmx .mll .mly .v .vo .ml4

.mli.cmi:
	$(if $(QUIET),@echo 'Ocamlc   $<' &&) $(OCAMLC) $(APRONLIB) $(ATPLIB) -c $(BFLAGS) $<

.ml.cmi:
	$(if $(QUIET),@echo 'Ocamlc   $<' &&) $(OCAMLC) $(APRONLIB) $(ATPLIB) -c $(BFLAGS) $<

.ml.cmo:
	$(if $(QUIET),@echo 'Ocamlc   $<' &&) $(OCAMLC) $(APRONLIB) $(ATPLIB) -c $(BFLAGS) $<

.ml.o:
	$(OCAMLOPT) $(APRONLIB) $(ATPLIB) -c $(OFLAGS) $<

.ml.cmx:
	$(if $(QUIET),@echo 'Ocamlopt $<' &&) $(OCAMLOPT) $(APRONLIB) $(ATPLIB) -c $(OFLAGS) $<

.mll.ml:
	$(OCAMLLEX) $<

.mly.ml:
	$(OCAMLYACC) -v $<

.mly.mli:
	$(OCAMLYACC) -v $<

.ml4.ml:
	$(CAMLP4) pr_o.cmo -impl $< > $@

lib/coq/%.vo: lib/coq/%.v
	$(COQC8) -I lib/coq $<

lib/coq-v7/%.vo: lib/coq-v7/%.v
	$(COQC7) -I lib/coq-v7 $<

jc/jc_ai.ml: jc/jc_annot_inference.ml jc/jc_annot_fail.ml Makefile
	if test "@enable_apron@" = "yes" ; then \
	  echo "# 1 \"jc/jc_annot_inference.ml\"" > jc/jc_ai.ml; \
	  cat jc/jc_annot_inference.ml >> jc/jc_ai.ml; \
	else \
	  echo "# 1 \"jc/jc_annot_fail.ml\"" > jc/jc_ai.ml; \
	  cat jc/jc_annot_fail.ml >> jc/jc_ai.ml; \
	fi

# %_why.v: %.mlw $(BINARY)
# 	$(BINARY) -coq $*.mlw

# %_why.pvs: %.mlw $(BINARY)
# 	$(BINARY) -pvs $*.mlw

# Emacs tags
############

tags:
	find src -name "*.ml*" | sort -r | xargs \
	etags "--regex=/let[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/let[ \t]+rec[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/and[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/type[ \t]+\([^ \t]+\)/\1/" \
              "--regex=/exception[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/val[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/module[ \t]+\([^ \t]+\)/\1/"

otags:
	otags src/*.mli src/*.ml c/*.mli c/*.ml intf/*.mli intf/*.ml

wc:
	ocamlwc -p src/*.ml* jc/*.ml* c/*.ml* intf/*.ml* tools/*.ml* java/*.ml*

# distrib
#########

NAME=why-$(VERSION)
EXPORT=export/$(NAME)

WWW = /users/www-perso/projets/why
FTP = $(WWW)/download
WWWKRAKATOA = /users/www-perso/projets/krakatoa

FILES =src/*.ml* c/*.ml* jc/*.ml* java/*.ml* ml/*.ml* ml/*/*.ml* intf/*.ml* tools/*.ml* tools/*.c bin/gwhy.sh \
       mix/*.ml* \
       version.sh Version Makefile.in configure.in configure .depend .depend.coq \
       config/check_ocamlgraph.ml \
       README INSTALL COPYING LICENSE CHANGES \
       doc/Makefile doc/manual.ps doc/why.1 \
	examples-c/*/*.h examples-c/*/*.c \
	examples-c/Makefile examples-c/*/Makefile \
	examples-c/*/coq/*.v \
	examples/Makefile* \
	examples/*/*.mlw examples/*/*.why examples/*/*.v examples/*/*.sx \
	examples/*/.depend examples/*/Makefile \
	bench/bench.in bench/good*/*.mlw bench/good*/*.v \
        bench/c/bench bench/c/bench-files bench/c/*/*.c bench/c/*/*/*.c \
	bench/jc/bench bench/jc/good/*.jc \
	bench/java/bench bench/java/*/*.java bench/provers/*.mlw \
	tests/regtest.sh tests/java/*.java \
	tests/java/coq/*.v \
	tests/java/result/README tests/java/oracle/*.oracle \
	lib/coq*/*.v \
	lib/pvs/pvscontext.el lib/pvs/*.pvs lib/pvs/*.prf \
	lib/mizar/why.miz lib/mizar/dict/why.voc \
	lib/why/*.why lib/isabelle/*.thy lib/hol4/*.ml lib/harvey/*.rv \
	lib/java_api/java/*/*.java \
	lib/javacard_api/java/lang/*.java \
	lib/javacard_api/javacard/*/*.java \
	lib/javacard_api/javacardx/crypto/*.java \
	lib/javacard_api/com/sun/javacard/impl/*.java \
	lib/images/*.png \
	atp/*.ml atp/LICENSE.txt atp/Makefile atp/Mk_ml_file \
	ocamlgraph/configure.in ocamlgraph/configure ocamlgraph/.depend \
	ocamlgraph/Makefile.in ocamlgraph/META.in ocamlgraph/*/*.ml* \
        frama-c-plugin/Makefile frama-c-plugin/configure \
	frama-c-plugin/*.ml* frama-c-plugin/share/jessie/*.h 

# ne pas distribuer ces tests-la	frama-c-plugin/tests/jessie/*.c

distrib export: source export-doc export-www export-examples export-examples-c linux

export-www:
	echo "<#def version>$(VERSION)</#def>" > /users/demons/filliatr/www/why/version.prehtml
	echo "<#def cversion>$(CVERSION)</#def>" >> /users/demons/filliatr/www/why/version.prehtml
	make -C /users/demons/filliatr/www/why install

source: export/$(NAME).tar.gz
	cp CHANGES CHANGES.caduceus export/$(NAME).tar.gz $(FTP)

export/$(NAME).tar.gz: $(FILES)
	rm -rf $(EXPORT)
	mkdir -p $(EXPORT)/bin
	cp --parents $(FILES) $(EXPORT)
	cd $(EXPORT); rm -f $(GENERATED)
	cd export; tar cf $(NAME).tar $(NAME); gzip -f --best $(NAME).tar

tarball-for-framac: 
	make tarball
	cp export/$(NAME).tar.gz export/why-for-framac.tar.gz

tarball: 
	mkdir -p export
	cd export; rm -rf $(NAME) $(NAME).tar.gz
	make export/$(NAME).tar.gz

EXFILES = lib/coq*/*.v examples/*/*.v examples/*/*.mlw

export-examples:
	cp --parents $(EXFILES) $(WWW)
	make -C $(WWW)/examples clean depend
	echo "*** faire make all dans $(WWW)/examples ***"

export-examples-c:
	mkdir -p $(WWW)/caduceus/examples
	cd examples-c; cp --parents */*.c */*.h $(WWW)/caduceus/examples
	mkdir -p $(WWW)/caduceus/examples/bench
	cp bench/c/good/*.c $(WWW)/caduceus/examples/bench
	rm -f $(WWW)/caduceus/examples/bench/test.c

export-doc: $(DOC)
	cp doc/manual.ps doc/manual.html $(WWW)/manual
	cp doc/logic_syntax.bnf $(WWW)/manual
	(cd $(WWW)/manual; hacha manual.html)
	cp doc/caduceus.ps doc/caduceus.html $(WWW)/caduceus/manual
	(cd $(WWW)/caduceus/manual; hacha caduceus.html)
	cp doc/krakatoa.pdf doc/krakatoa.html $(WWWKRAKATOA)/manual
	(cd $(WWWKRAKATOA)/manual; hacha krakatoa.html)

OSTYPE  ?= linux

BINARYNAME = $(NAME)-$(OSTYPE)

linux: binary

ALLBINARYFILES = $(FILES) $(BINARYFILES) 

binary: $(ALLBINARYFILES)
	mkdir -p export/$(BINARYNAME)
	cp --parents $(ALLBINARYFILES) export/$(BINARYNAME)
	(cd export; tar czf $(BINARYNAME).tar.gz $(BINARYNAME))
	cp export/$(BINARYNAME).tar.gz $(FTP)

# file headers
##############
headers:
Jean-Christophe Filliâtre's avatar
headers  
Jean-Christophe Filliâtre committed
1128 1129 1130
	headache -c misc/headache_config.txt -h misc/header.txt \
		Makefile.in configure.in \
		*/*.ml */*.ml[ily4] 
Jean-Christophe Filliâtre's avatar
Jean-Christophe Filliâtre committed
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225

# myself
########

Makefile: Makefile.in config.status
	./config.status

config.status: configure
	./config.status --recheck

configure: configure.in
	autoconf 

# clean and depend
##################

clean::
	rm -f src/*.cm[iox] src/*.o src/*~ src/*.annot src/*.output
	rm -f c/*.cm[iox] c/*.o c/*~ c/*.annot c/*.output
	rm -f intf/*.cm[iox] intf/*.o intf/*~ intf/*.annot
	rm -f tools/*.cm[iox] tools/*.o tools/*~ tools/*.annot
	rm -f jc/*.cm[iox] jc/*.o jc/*~ jc/*.annot jc/*.output
	rm -f java/*.cm[iox] java/*.o java/*~ java/*.annot java/*.output
	rm -f ml/*.cm[iox] ml/*.o ml/*~ ml/*.annot
	rm -f ml/parsing/*.cm[iox] ml/parsing/*.o ml/parsing/*~ \
		ml/parsing/*.annot ml/parsing/*.output
	rm -f ml/utils/*.cm[iox] ml/utils/*.o ml/utils/*~ ml/utils/*.annot
	rm -f ml/typing/*.cm[iox] ml/typing/*.o ml/typing/*~ ml/typing/*.annot
	rm -f bin/why.opt bin/why.byte bin/why.static bin/top
	rm -f bin/caduceus.opt bin/caduceus.byte
	rm -f bin/jessie.opt bin/jessie.byte
	rm -f bin/jessica.opt bin/jessica.byte
	rm -f bin/why-obfuscator.opt bin/why-obfuscator.byte
	rm -f bin/rv_merge.opt bin/rv_merge.byte
	rm -f bin/why-stat.opt bin/why-stat.byte
	rm -f bin/tool-stat.opt bin/tool-stat.byte
	rm -f bin/why2html.opt bin/why2html.byte
	rm -f bin/why-dp.opt bin/why-dp.byte
	rm -f bin/why-cpulimit
	rm -f lib/coq*/*.vo lib/coq*/*~
	rm -f $(GENERATED)
#	make -C atp clean
#	make -C doc clean
#	if test -d examples-v7; then \
#		make -C examples-v7 clean ; \
#	fi
#	make -C examples clean

dist-clean:: clean
	rm -f Makefile config.status config.cache config.log

coq-clean::
	rm -f lib/coq*/*.vo examples/*/*.vo
	rm .depend.coq

.PHONY: depend
.depend depend: $(GENERATED)
	rm -f .depend
	$(OCAMLDEP) -slash $(INCLUDES) src/*.ml src/*.mli jc/*.mli jc/*.ml c/*.mli c/*.ml java/*.mli java/*.ml intf/*.ml intf/*.mli tools/*.mli tools/*.ml mix/*.mli mix/*.ml ml/*.ml ml/*.mli > .depend
	$(OCAMLDEP) -slash $(MLINCLUDES) ml/parsing/*.ml ml/parsing/*.mli ml/typing/*.ml ml/typing/*.mli ml/utils/*.ml ml/utils/*.mli >> .depend
ifeq ($(FRAMAC),yes)
#	$(MAKE) -C $(JESSIE_PLUGIN_PATH) depend
endif

.depend.coq: #lib/coq*/*.v
	if test @COQ@ = yes; then \
	  rm -f .depend.coq; \
	  $(COQDEP) -I lib/coq lib/coq/*.v > .depend.coq; \
	  $(COQDEP) -I lib/coq-v7 lib/coq-v7/*.v >> .depend.coq; \
	else touch .depend.coq; \
	fi

alldepend:
	make -C examples-v7 depend
	make -C examples depend

include .depend
include .depend.coq

#################################################################
# Building the Why platform with ocamlbuild (OCaml 3.10 needed) #
#################################################################

# There used to be targets here but they are no longer useful.

# To build using Ocamlbuild:
# 1) Run "make Makefile" to ensure that the generated files (version.ml, ...)
# are generated.
# 2) Run Ocamlbuild with any target to generate the sanitization script.
# 3) Run ./sanitize to delete the generated files that shouldn't be generated
# (i.e. all lexers and parsers).
# 4) Run Ocamlbuild with the target you need, for example:
# ocamlbuild jc/jc_main.native

# You can also use the Makefile ./build.makefile which has some handy targets.