| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
[@@@ocaml.warning "+a"] |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
open Printf |
| 17 |
open Conf |
| 18 |
open Util |
| 19 |
|
| 20 |
open! CmdArgs |
| 21 |
open CmdArgs.Prefs |
| 22 |
|
| 23 |
let (/) = Filename.concat |
| 24 |
|
| 25 |
let coq_version = "9.2" |
| 26 |
|
| 27 |
|
| 28 |
let vo_magic = 90299 |
| 29 |
let is_a_released_version = true |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
type camlexec = { mutable find : string } |
| 34 |
let camlexec = { find = "ocamlfind" } |
| 35 |
|
| 36 |
let reset_caml_find c o = c.find <- o |
| 37 |
|
| 38 |
|
| 39 |
let arch prefs = arch prefs.arch |
| 40 |
|
| 41 |
|
| 42 |
let arch_is_win32 arch = arch = "win32" |
| 43 |
|
| 44 |
let unix arch = os_type_cygwin || not (arch_is_win32 arch) |
| 45 |
|
| 46 |
|
| 47 |
let resolve_binary_suffix arch = if unix arch then "" else ".exe" |
| 48 |
|
| 49 |
|
| 50 |
let install_precommit_hook prefs = |
| 51 |
let f = ".git/hooks/pre-commit" in |
| 52 |
if dir_exists ".git/hooks" && not (Sys.file_exists f) then begin |
| 53 |
cprintf prefs "Creating pre-commit hook in %s" f; |
| 54 |
let o = open_out f in |
| 55 |
let pr s = fprintf o s in |
| 56 |
pr "#!/bin/sh\n"; |
| 57 |
pr "\n"; |
| 58 |
pr "if [ -x dev/tools/pre-commit ]; then\n"; |
| 59 |
pr " exec dev/tools/pre-commit\n"; |
| 60 |
pr "fi\n"; |
| 61 |
close_out o; |
| 62 |
Unix.chmod f 0o775 |
| 63 |
end |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
let browser prefs arch = |
| 68 |
match prefs.browser with |
| 69 |
| Some b -> b |
| 70 |
| None when arch_is_win32 arch -> {|start "%s"|} |
| 71 |
| None when arch = "Darwin" -> {|open "%s"|} |
| 72 |
| _ -> {|xdg-open "%s"|} |
| 73 |
|
| 74 |
|
| 75 |
module CamlConf = struct |
| 76 |
type t = |
| 77 |
{ camlbin : string |
| 78 |
; caml_version : string |
| 79 |
; camllib : string |
| 80 |
; findlib_version : string |
| 81 |
} |
| 82 |
end |
| 83 |
|
| 84 |
let resolve_caml () = |
| 85 |
let () = |
| 86 |
try reset_caml_find camlexec (which camlexec.find) |
| 87 |
with Not_found -> |
| 88 |
die (sprintf "Error: cannot find '%s' in your path!\n" camlexec.find ^ |
| 89 |
"Please adjust your path or use the -ocamlfind option of ./configure") |
| 90 |
in |
| 91 |
if not (is_executable camlexec.find) |
| 92 |
then die ("Error: cannot find the executable '"^camlexec.find^"'.") |
| 93 |
else |
| 94 |
let findlib_version, _ = run camlexec.find ["query"; "findlib"; "-format"; "%v"] in |
| 95 |
let caml_version, _ = run camlexec.find ["ocamlc";"-version"] in |
| 96 |
let camllib, _ = run camlexec.find ["printconf";"stdlib"] in |
| 97 |
let camlbin = |
| 98 |
Filename.dirname (Filename.dirname camllib) / "bin/" in |
| 99 |
{ CamlConf.camlbin; caml_version; camllib; findlib_version } |
| 100 |
|
| 101 |
|
| 102 |
let caml_version_nums { CamlConf.caml_version; _ } = |
| 103 |
generic_version_nums ~name:"the OCaml compiler" caml_version |
| 104 |
|
| 105 |
external native_available : unit -> bool = "rocq_native_available" |
| 106 |
|
| 107 |
let check_caml_version prefs caml_version caml_version_nums = |
| 108 |
if prefs.nativecompiler <> NativeNo && not (native_available ()) then |
| 109 |
let () = cprintf prefs "Your version of OCaml is %s." caml_version in |
| 110 |
if caml_version_nums >= [5;0;0] then |
| 111 |
die "You have enabled Rocq's native compiler, however it is not compatible with OCaml >= 5.0.0 on this architecture" |
| 112 |
else |
| 113 |
die "You have enabled Rocq's native compiler, however it is not compatible with your OCaml compiler" |
| 114 |
else if caml_version_nums >= [4;14;0] then |
| 115 |
cprintf prefs "You have OCaml %s. Good!" caml_version |
| 116 |
else |
| 117 |
let () = cprintf prefs "Your version of OCaml is %s." caml_version in |
| 118 |
die "You need OCaml 4.14.0 or later." |
| 119 |
|
| 120 |
let check_findlib_version prefs { CamlConf.findlib_version; _ } = |
| 121 |
let findlib_version_nums = generic_version_nums ~name:"findlib" findlib_version in |
| 122 |
if findlib_version_nums >= [1;9;1] then |
| 123 |
cprintf prefs "You have OCamlfind %s. Good!" findlib_version |
| 124 |
else |
| 125 |
let () = cprintf prefs "Your version of OCamlfind is %s." findlib_version in |
| 126 |
die "You need OCamlfind 1.9.1 or later." |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
let coq_warnings = "-w -a+1..3-4+5..8-9+10..26-27+28..39-40-41-42+43-44-45+46..47-48+49..57-58+59..66-67-68+69-70" |
| 147 |
|
| 148 |
|
| 149 |
let caml_flags = |
| 150 |
Printf.sprintf "-thread -bin-annot -strict-sequence %s" coq_warnings |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
let msg_byteonly = |
| 155 |
"Only the bytecode version of Rocq will be available." |
| 156 |
|
| 157 |
let msg_no_ocamlopt () = |
| 158 |
warn "Cannot find the OCaml native-code compiler.\n%s" msg_byteonly |
| 159 |
|
| 160 |
let msg_no_dynlink_cmxa prefs = |
| 161 |
warn "Cannot find native-code dynlink library.\n%s" msg_byteonly; |
| 162 |
cprintf prefs "For building a native-code Rocq, you may try to first"; |
| 163 |
cprintf prefs "compile and install a dummy dynlink.cmxa (see dev/dynlink.ml)"; |
| 164 |
cprintf prefs "and then run ./configure -natdynlink no" |
| 165 |
|
| 166 |
let check_native prefs camlenv = |
| 167 |
let version, _ = tryrun camlexec.find ["opt";"-version"] in |
| 168 |
if version = "" then let () = msg_no_ocamlopt () in raise Not_found |
| 169 |
else if fst (tryrun camlexec.find ["query";"dynlink"]) = "" |
| 170 |
then let () = msg_no_dynlink_cmxa prefs in raise Not_found |
| 171 |
else |
| 172 |
let () = |
| 173 |
let { CamlConf.caml_version; _ } = camlenv in |
| 174 |
if version <> caml_version then |
| 175 |
warn "Native and bytecode compilers do not have the same version!" |
| 176 |
in cprintf prefs "You have native-code compilation. Good!" |
| 177 |
|
| 178 |
let best_compiler prefs camlenv = |
| 179 |
try check_native prefs camlenv; "opt" with Not_found -> "byte" |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
let hasnatdynlink prefs best_compiler = prefs.natdynlink && best_compiler = "opt" |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
let check_for_zarith prefs = |
| 190 |
let zarith,_ = tryrun camlexec.find ["query";"zarith"] in |
| 191 |
let zarith_cmai base = Sys.file_exists (base / "z.cmi") && Sys.file_exists (base / "zarith.cma") in |
| 192 |
let zarith_version, _ = run camlexec.find ["query"; "zarith"; "-format"; "%v"] in |
| 193 |
match zarith with |
| 194 |
| "" -> |
| 195 |
die "Zarith library not installed, required" |
| 196 |
| _ when not (zarith_cmai zarith) -> |
| 197 |
die "Zarith library installed but no development files found (try installing the -dev package)" |
| 198 |
| _ -> |
| 199 |
let zarith_version_int = generic_version_nums ~name:"Zarith" zarith_version in |
| 200 |
if zarith_version_int >= [1;11;0] then |
| 201 |
cprintf prefs "You have the Zarith library %s installed. Good!" zarith_version |
| 202 |
else |
| 203 |
die ("Zarith version 1.11 is required, you have " ^ zarith_version) |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
let coqsrc = Sys.getcwd () |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
type path_style = |
| 213 |
| Absolute of string |
| 214 |
| Relative of string |
| 215 |
|
| 216 |
type relocatable_path = |
| 217 |
| Relocatable of string |
| 218 |
| NotRelocatable of string |
| 219 |
|
| 220 |
module InstallDir = struct |
| 221 |
|
| 222 |
type t = |
| 223 |
{ var : string |
| 224 |
|
| 225 |
; msg : string |
| 226 |
|
| 227 |
; uservalue : string option |
| 228 |
|
| 229 |
; selfcontainedlayout : path_style |
| 230 |
|
| 231 |
; unixlayout : path_style |
| 232 |
|
| 233 |
} |
| 234 |
|
| 235 |
let make var msg uservalue selfcontainedlayout unixlayout = |
| 236 |
{ var; msg; uservalue; selfcontainedlayout; unixlayout } |
| 237 |
|
| 238 |
end |
| 239 |
|
| 240 |
let install prefs = |
| 241 |
[ InstallDir.make "COQPREFIX" "Prefix" None (Relative "") (Relative "") |
| 242 |
; InstallDir.make "COQLIBINSTALL" "the Rocq library" prefs.libdir (Relative "lib/coq") (Relative "lib/coq") |
| 243 |
; InstallDir.make "CONFIGDIR" "the Rocqide configuration files" prefs.configdir (Relative "config") (Absolute "/etc/xdg/coq") |
| 244 |
; InstallDir.make "DATADIR" "the Rocqide data files" prefs.datadir (Relative "share/coq") (Relative "share/coq") |
| 245 |
; InstallDir.make "DOCDIR" "documentation prefix path for all Rocq packages" prefs.docdir (Relative "share/doc") (Relative "share/doc") |
| 246 |
] |
| 247 |
|
| 248 |
let strip_trailing_slash_if_any p = |
| 249 |
if p.[String.length p - 1] = '/' then String.sub p 0 (String.length p - 1) else p |
| 250 |
|
| 251 |
let use_suffix prefix suff = |
| 252 |
match suff with |
| 253 |
| Absolute path -> NotRelocatable path |
| 254 |
| Relative suff -> |
| 255 |
match prefix with |
| 256 |
| Prefix prefix -> NotRelocatable (if suff = "" then prefix else prefix ^ "/" ^ suff) |
| 257 |
| RelocatableInstall -> Relocatable suff |
| 258 |
|
| 259 |
let relativize = function |
| 260 |
|
| 261 |
| Relative _ as suffix -> suffix |
| 262 |
| Absolute path -> Relative (String.sub path 1 (String.length path - 1)) |
| 263 |
|
| 264 |
let find_suffix prefix path = match prefix with |
| 265 |
| None | Some RelocatableInstall -> Absolute path |
| 266 |
| Some (Prefix p) -> |
| 267 |
let p = strip_trailing_slash_if_any p in |
| 268 |
let lpath = String.length path in |
| 269 |
let lp = String.length p in |
| 270 |
if lpath > lp && String.sub path 0 lp = p then |
| 271 |
Relative (String.sub path (lp+1) (lpath - lp - 1)) |
| 272 |
else |
| 273 |
Absolute path |
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
let do_one_instdir ~interactive ~prefix ~arch InstallDir.{var; msg; uservalue; selfcontainedlayout; unixlayout} = |
| 279 |
(var,msg), |
| 280 |
match uservalue, prefix with |
| 281 |
| Some d, p -> NotRelocatable d, find_suffix p d |
| 282 |
| None, Some p -> |
| 283 |
let suffix = if (arch_is_win32 arch) then selfcontainedlayout else relativize unixlayout in |
| 284 |
use_suffix p suffix, suffix |
| 285 |
| None, None -> |
| 286 |
let () = if not interactive then die (Printf.sprintf "No installation path given for %s" msg) in |
| 287 |
let suffix = if (unix arch) then unixlayout else selfcontainedlayout in |
| 288 |
let base = if (unix arch) then "/usr/local" else "C:/coq" in |
| 289 |
let dflt = use_suffix (Prefix base) suffix in |
| 290 |
let ppdflt = match dflt with NotRelocatable v -> v | Relocatable _ -> assert false in |
| 291 |
let () = printf "Where should I install %s [%s]? " msg ppdflt in |
| 292 |
let line = read_line () in |
| 293 |
if line = "" then (dflt,suffix) else (NotRelocatable line,find_suffix prefix line) |
| 294 |
|
| 295 |
let install_dirs prefs arch = |
| 296 |
let prefix = prefs.prefix in |
| 297 |
List.map (do_one_instdir ~interactive:prefs.interactive ~prefix ~arch) (install prefs) |
| 298 |
|
| 299 |
let select var install_dirs = List.find (fun ((v,_),_) -> v=var) install_dirs |> snd |
| 300 |
|
| 301 |
module CoqEnv = struct |
| 302 |
|
| 303 |
type t = |
| 304 |
{ coqlib : relocatable_path |
| 305 |
; coqlibsuffix : path_style |
| 306 |
; docdir : relocatable_path |
| 307 |
; docdirsuffix : path_style |
| 308 |
; configdir : relocatable_path |
| 309 |
; configdirsuffix : path_style |
| 310 |
; datadir : relocatable_path |
| 311 |
; datadirsuffix : path_style } |
| 312 |
end |
| 313 |
|
| 314 |
let resolve_coqenv install_dirs = |
| 315 |
let coqlib, coqlibsuffix = select "COQLIBINSTALL" install_dirs in |
| 316 |
let docdir, docdirsuffix = select "DOCDIR" install_dirs in |
| 317 |
let configdir, configdirsuffix = select "CONFIGDIR" install_dirs in |
| 318 |
let datadir,datadirsuffix = select "DATADIR" install_dirs in |
| 319 |
{ CoqEnv.coqlib; coqlibsuffix; docdir; docdirsuffix |
| 320 |
; configdir; configdirsuffix; datadir; datadirsuffix } |
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
let cflags_dflt = "-Wall -Wno-unused -g -O2" |
| 329 |
|
| 330 |
let cflags_sse2 = "-msse2 -mfpmath=sse" |
| 331 |
|
| 332 |
|
| 333 |
let compute_cflags prefs = |
| 334 |
let cflags = Buffer.create 17 in |
| 335 |
Buffer.add_string cflags cflags_dflt; |
| 336 |
let sse2_math = |
| 337 |
let _, slurp = |
| 338 |
|
| 339 |
tryrun camlexec.find |
| 340 |
["ocamlc"; "-ccopt"; cflags_dflt ^ " -march=native -dM -E " ^ cflags_sse2; |
| 341 |
"-c"; coqsrc/"dev/header.c"] in |
| 342 |
List.exists (fun line -> starts_with line "#define __SSE2_MATH__ 1") slurp in |
| 343 |
if sse2_math then |
| 344 |
begin |
| 345 |
Buffer.add_char cflags ' '; |
| 346 |
Buffer.add_string cflags cflags_sse2 |
| 347 |
end; |
| 348 |
if prefs.nativecompiler = NativeNo then |
| 349 |
Buffer.add_string cflags " -DNO_NATIVE_COMPUTE"; |
| 350 |
(Buffer.contents cflags, sse2_math) |
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
let check_fmath sse2_math = |
| 362 |
let add = (+.) in |
| 363 |
let b = ldexp 1. 53 in |
| 364 |
let s = add 1. (ldexp 1. (-52)) in |
| 365 |
if (add b s <= b || add b 1. <> b || ldexp 1. (-1074) <= 0.) |
| 366 |
&& not sse2_math then |
| 367 |
die "Detected non IEEE-754 compliant architecture (or wrong \ |
| 368 |
rounding mode). Use of Float is thus unsafe." |
| 369 |
|
| 370 |
let esc s = if String.contains s ' ' then "\"" ^ s ^ "\"" else s |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
let pr_native = function |
| 375 |
| NativeYes -> "yes" | NativeNo -> "no" | NativeOndemand -> "ondemand" |
| 376 |
|
| 377 |
let print_summary prefs arch camlenv install_dirs browser = |
| 378 |
let { CamlConf.caml_version; camlbin; camllib; _ } = camlenv in |
| 379 |
let pr s = printf s in |
| 380 |
let pr_reloc oc = function |
| 381 |
| NotRelocatable p -> fprintf oc "%s" (esc p) |
| 382 |
| Relocatable p -> fprintf oc "(relocatable prefix)/%s" (esc p) |
| 383 |
in |
| 384 |
pr "\n"; |
| 385 |
pr " Architecture : %s\n" arch; |
| 386 |
pr " Sys.os_type : %s\n" Sys.os_type; |
| 387 |
pr " OCaml version : %s\n" caml_version; |
| 388 |
pr " OCaml binaries in : %s\n" (esc camlbin); |
| 389 |
pr " OCaml library in : %s\n" (esc camllib); |
| 390 |
pr " Web browser : %s\n" browser; |
| 391 |
pr " Rocq web site : %s\n" prefs.coqwebsite; |
| 392 |
pr " Bytecode VM enabled : %B\n" prefs.bytecodecompiler; |
| 393 |
pr " Native Compiler enabled : %s\n\n" (pr_native prefs.nativecompiler); |
| 394 |
(pr " Paths where installation is expected by Rocq Makefile:\n"; |
| 395 |
List.iter |
| 396 |
(fun ((_,msg),(dir,_)) -> pr " - %s is expected in %a\n" msg pr_reloc dir) |
| 397 |
install_dirs); |
| 398 |
pr "\n"; |
| 399 |
pr "If anything is wrong above, please restart './configure'.\n\n"; |
| 400 |
pr "*Warning* To compile the system for a new architecture\n"; |
| 401 |
pr " don't forget to do a 'make clean' before './configure'.\n" |
| 402 |
|
| 403 |
|
| 404 |
let write_coq_config_ml install_prefix camlenv coqenv caml_flags caml_version_nums arch arch_is_win32 hasnatdynlink browser prefs o = |
| 405 |
let { CoqEnv.coqlib; coqlibsuffix; configdir; configdirsuffix; docdir; docdirsuffix; datadir; datadirsuffix } = coqenv in |
| 406 |
let { CamlConf.caml_version; _ } = camlenv in |
| 407 |
let pr s = fprintf o s in |
| 408 |
let pr_s = pr "let %s = %S\n" in |
| 409 |
let pr_b = pr "let %s = %B\n" in |
| 410 |
let pr_i32 = pr "let %s = %dl\n" in |
| 411 |
let pr_p s o = pr "let %s = %S\n" s |
| 412 |
(match o with Relative s -> s | Absolute s -> s) in |
| 413 |
let pr_reloc s = function |
| 414 |
| NotRelocatable o -> pr "let %s = NotRelocatable %S\n" s o |
| 415 |
| Relocatable o -> pr "let %s = Relocatable %S\n" s o |
| 416 |
in |
| 417 |
let pr_li n l = pr "let %s = [%s]\n" n (String.concat ";" (List.map string_of_int l)) in |
| 418 |
pr "(* DO NOT EDIT THIS FILE: automatically generated by ../configure *)\n"; |
| 419 |
pr "(* Exact command that generated this file: *)\n"; |
| 420 |
pr "(* %s *)\n\n" (String.concat " " (Array.to_list Sys.argv)); |
| 421 |
pr "let gc_ramp_up f = %s\n" |
| 422 |
(if caml_version_nums >= [5;4;0] then "fst (Gc.ramp_up f)" else "f ()"); |
| 423 |
pr "type relocatable_path = NotRelocatable of string | Relocatable of string\n"; |
| 424 |
pr_reloc "install_prefix" install_prefix; |
| 425 |
pr_reloc "coqlib" coqlib; |
| 426 |
pr_reloc "configdir" configdir; |
| 427 |
pr_reloc "datadir" datadir; |
| 428 |
pr_reloc "docdir" docdir; |
| 429 |
pr_p "coqlibsuffix" coqlibsuffix; |
| 430 |
pr_p "configdirsuffix" configdirsuffix; |
| 431 |
pr_p "datadirsuffix" datadirsuffix; |
| 432 |
pr_p "docdirsuffix" docdirsuffix; |
| 433 |
pr_s "ocamlfind" camlexec.find; |
| 434 |
pr_s "caml_flags" caml_flags; |
| 435 |
pr_s "version" coq_version; |
| 436 |
pr_s "caml_version" caml_version; |
| 437 |
pr_li "caml_version_nums" caml_version_nums; |
| 438 |
pr_s "arch" arch; |
| 439 |
pr_b "arch_is_win32" arch_is_win32; |
| 440 |
pr_s "exec_extension" !exe; |
| 441 |
pr_b "has_natdynlink" hasnatdynlink; |
| 442 |
pr_i32 "vo_version" vo_magic; |
| 443 |
pr_s "browser" browser; |
| 444 |
pr_s "wwwcoq" prefs.coqwebsite; |
| 445 |
pr_s "wwwbugtracker" (prefs.coqwebsite ^ "bugs/"); |
| 446 |
pr_s "wwwrefman" (prefs.coqwebsite ^ "doc/V" ^ coq_version ^ "/refman/"); |
| 447 |
pr_s "wwwstdlib" (prefs.coqwebsite ^ "doc/V" ^ coq_version ^ "/corelib/"); |
| 448 |
pr_b "bytecode_compiler" prefs.bytecodecompiler; |
| 449 |
pr "type native_compiler = NativeOff | NativeOn of { ondemand : bool }\n"; |
| 450 |
pr "let native_compiler = %s\n" |
| 451 |
(match prefs.nativecompiler with |
| 452 |
| NativeYes -> "NativeOn {ondemand=false}" | NativeNo -> "NativeOff" |
| 453 |
| NativeOndemand -> "NativeOn {ondemand=true}"); |
| 454 |
|
| 455 |
let core_src_dirs = [ "boot"; "config"; "lib"; "clib"; "kernel"; "library"; |
| 456 |
"engine"; "pretyping"; "interp"; "gramlib"; "parsing"; "proofs"; |
| 457 |
"tactics"; "toplevel"; "printing"; "ide"; "stm"; "vernac" ] in |
| 458 |
|
| 459 |
let core_src_dirs = List.fold_left (fun acc core_src_subdir -> acc ^ " \"" ^ core_src_subdir ^ "\";\n") |
| 460 |
"" |
| 461 |
core_src_dirs in |
| 462 |
|
| 463 |
pr "\nlet core_src_dirs = [\n%s]\n" core_src_dirs; |
| 464 |
pr "\nlet plugins_dirs = [\n"; |
| 465 |
|
| 466 |
let plugins = match open_in "config/plugin_list" with |
| 467 |
| exception Sys_error _ -> |
| 468 |
let plugins = |
| 469 |
try Sys.readdir "plugins" |
| 470 |
with _ -> [||] |
| 471 |
in |
| 472 |
Array.sort compare plugins; |
| 473 |
plugins |
| 474 |
| ch -> Array.of_list (snd (read_lines_and_close ch)) |
| 475 |
in |
| 476 |
Array.iter |
| 477 |
(fun f -> |
| 478 |
let f' = "plugins/"^f in |
| 479 |
if Sys.is_directory f' && f.[0] <> '.' then pr " %S;\n" f') |
| 480 |
plugins; |
| 481 |
pr "]\n"; |
| 482 |
|
| 483 |
pr "\nlet all_src_dirs = core_src_dirs @ plugins_dirs\n" |
| 484 |
|
| 485 |
|
| 486 |
let write_coq_byte_config_ml caml_version_nums o = |
| 487 |
let pr s = fprintf o s in |
| 488 |
pr "let toploop_use_silently ppf f = %s\n" |
| 489 |
(if caml_version_nums >= [4;14;0] |
| 490 |
then "Toploop.use_silently ppf (Toploop.File f)" |
| 491 |
else "Toploop.use_silently ppf f"); |
| 492 |
pr "let compenv_handle_exit_with_status_0 f = %s\n" |
| 493 |
(if caml_version_nums >= [4;12;0] |
| 494 |
then "try f () with Compenv.Exit_with_status(0) -> ()" |
| 495 |
else "f ()"); |
| 496 |
pr "let toploop_prep_and_loop fmt = %s\n" |
| 497 |
(if caml_version_nums >= [5;3;0] |
| 498 |
then "ignore (Toploop.prepare fmt () : bool); Toploop.loop fmt" |
| 499 |
else "Toploop.loop fmt") |
| 500 |
|
| 501 |
|
| 502 |
let write_dune_c_flags cflags o = |
| 503 |
let pr s = fprintf o s in |
| 504 |
pr "(%s)\n" cflags |
| 505 |
|
| 506 |
|
| 507 |
let write_coq_config_py o = |
| 508 |
let pr s = fprintf o s in |
| 509 |
pr "# DO NOT EDIT THIS FILE: automatically generated by ../configure\n"; |
| 510 |
pr "version = '%s'\n" coq_version; |
| 511 |
pr "is_a_released_version = %s\n" (if is_a_released_version then "True" else "False") |
| 512 |
|
| 513 |
|
| 514 |
let main () = |
| 515 |
let prefs = CmdArgs.parse_args () in |
| 516 |
Util.debug := prefs.debug; |
| 517 |
let arch = arch prefs in |
| 518 |
let arch_is_win32 = arch_is_win32 arch in |
| 519 |
let exe = resolve_binary_suffix arch in |
| 520 |
Util.exe := exe; |
| 521 |
install_precommit_hook prefs; |
| 522 |
let browser = browser prefs arch in |
| 523 |
let camlenv = resolve_caml () in |
| 524 |
let caml_version_nums = caml_version_nums camlenv in |
| 525 |
check_caml_version prefs camlenv.CamlConf.caml_version caml_version_nums; |
| 526 |
check_findlib_version prefs camlenv; |
| 527 |
let best_compiler = best_compiler prefs camlenv in |
| 528 |
let hasnatdynlink = hasnatdynlink prefs best_compiler in |
| 529 |
check_for_zarith prefs; |
| 530 |
let install_dirs = install_dirs prefs arch in |
| 531 |
let install_prefix = select "COQPREFIX" install_dirs |> fst in |
| 532 |
let coqenv = resolve_coqenv install_dirs in |
| 533 |
let cflags, sse2_math = compute_cflags prefs in |
| 534 |
check_fmath sse2_math; |
| 535 |
if not prefs.quiet then |
| 536 |
print_summary prefs arch camlenv install_dirs browser; |
| 537 |
write_config_file ~file:"config/coq_config.ml" |
| 538 |
(write_coq_config_ml install_prefix camlenv coqenv caml_flags caml_version_nums arch arch_is_win32 hasnatdynlink browser prefs); |
| 539 |
write_config_file ~file:"config/coq_byte_config.ml" (write_coq_byte_config_ml caml_version_nums); |
| 540 |
write_config_file ~file:"config/dune.c_flags" (write_dune_c_flags cflags); |
| 541 |
write_config_file ~file:"config/coq_config.py" write_coq_config_py; |
| 542 |
() |
| 543 |
|
| 544 |
let _ = |
| 545 |
main () |