aboutsummaryrefslogtreecommitdiffhomepage
path: root/configure.ml
diff options
context:
space:
mode:
authorGravatar Maxime Dénès <mail@maximedenes.fr>2017-12-11 23:18:36 +0100
committerGravatar Maxime Dénès <mail@maximedenes.fr>2017-12-11 23:18:36 +0100
commit3a56a7f7ec35286360fef5a661634a86c5a13daf (patch)
tree8836f27f992c40314f1c52faae010f1f2f752db2 /configure.ml
parent0275b5802ffd416dd0ed739955445a1c3c0287e9 (diff)
parent801147a25196d01f280a80fb3e64e644cfc92d83 (diff)
Merge PR #6312: [configure] fix detection of `md5sum`
Diffstat (limited to 'configure.ml')
-rw-r--r--configure.ml21
1 files changed, 18 insertions, 3 deletions
diff --git a/configure.ml b/configure.ml
index c7d25bfc8..3850f119b 100644
--- a/configure.ml
+++ b/configure.ml
@@ -178,6 +178,20 @@ let which prog =
let program_in_path prog =
try let _ = which prog in true with Not_found -> false
+(** Choose a command among a list of candidates
+ (command name, mandatory arguments, arguments for this test).
+ Chooses the first one whose execution outputs a non-empty (first) line.
+ Dies with message [msg] if none is found. *)
+
+let select_command msg candidates =
+ let rec search = function
+ | [] -> die msg
+ | (p, x, y) :: tl ->
+ if fst (tryrun p (x @ y)) <> ""
+ then List.fold_left (Printf.sprintf "%s %s") p x
+ else search tl
+ in search candidates
+
(** As per bug #4828, ocamlfind on Windows/Cygwin barfs if you pass it
a quoted path to camlpXo via -pp. So we only quote camlpXo on not
Windows, and warn on Windows if the path contains spaces *)
@@ -853,9 +867,10 @@ let strip =
(** * md5sum command *)
let md5sum =
- if List.mem arch ["Darwin"; "FreeBSD"; "OpenBSD"]
- then "md5 -q" else "md5sum"
-
+ select_command "Don’t know how to compute MD5 checksums…" [
+ "md5sum", [], [ "--version" ];
+ "md5", ["-q"], [ "-s" ; "''" ];
+ ]
(** * Documentation : do we have latex, hevea, ... *)