From 5557c23a1cc33b825734403c29c5cca5685d22f0 Mon Sep 17 00:00:00 2001 From: Gaƫtan Gilbert Date: Sun, 19 Nov 2017 13:59:46 +0100 Subject: Check findlib version in configure (fix #4270). --- configure.ml | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'configure.ml') diff --git a/configure.ml b/configure.ml index 51f3fad7c..86f6b7fe3 100644 --- a/configure.ml +++ b/configure.ml @@ -266,6 +266,7 @@ module Prefs = struct let nativecompiler = ref (not (os_type_win32 || os_type_cygwin)) let coqwebsite = ref "http://coq.inria.fr/" let force_caml_version = ref false + let force_findlib_version = ref false let warn_error = ref false end @@ -334,6 +335,8 @@ let args_options = Arg.align [ " URL of the coq website"; "-force-caml-version", Arg.Set Prefs.force_caml_version, " Force OCaml version"; + "-force-findlib-version", Arg.Set Prefs.force_findlib_version, + " Force findlib version"; "-warn-error", Arg.Set Prefs.warn_error, " Make OCaml warnings into errors"; "-camldir", Arg.String (fun _ -> ()), @@ -439,7 +442,7 @@ let browser = (** * OCaml programs *) -let camlbin, caml_version, camllib = +let camlbin, caml_version, camllib, findlib_version = let () = match !Prefs.ocamlfindcmd with | Some cmd -> reset_caml_find camlexec cmd | None -> @@ -451,6 +454,7 @@ let camlbin, caml_version, camllib = if not (is_executable camlexec.find) then die ("Error: cannot find the executable '"^camlexec.find^"'.") else + let findlib_version, _ = run camlexec.find ["query"; "findlib"; "-format"; "%v"] in let caml_version, _ = run camlexec.find ["ocamlc";"-version"] in let camllib, _ = run camlexec.find ["printconf";"stdlib"] in let camlbin = (* TODO beurk beurk beurk *) @@ -461,7 +465,7 @@ let camlbin, caml_version, camllib = let () = if is_executable (camlbin / "ocaml") then reset_caml_top camlexec (camlbin / "ocaml") in - camlbin, caml_version, camllib + camlbin, caml_version, camllib, findlib_version let camlp4compat = "-loc loc" @@ -491,6 +495,28 @@ let check_caml_version () = let _ = check_caml_version () +let findlib_version_list = numeric_prefix_list findlib_version + +let findlib_version_nums = + try + if List.length findlib_version_list < 2 then failwith "bad version"; + List.map s2i findlib_version_list + with _ -> + die ("I found ocamlfind but cannot read its version number!\n" ^ + "Is it installed properly?") + +let check_findlib_version () = + if findlib_version_nums >= [1;4;1] then + printf "You have OCamlfind %s. Good!\n" findlib_version + else + let () = printf "Your version of OCamlfind is %s.\n" findlib_version in + if !Prefs.force_findlib_version then + printf "*Warning* Your version of OCamlfind is outdated.\n" + else + die "You need OCamlfind 1.4.1 or later." + +let _ = check_findlib_version () + let camltag = match caml_version_list with | x::y::_ -> "OCAML"^x^y | _ -> assert false -- cgit v1.2.3