aboutsummaryrefslogtreecommitdiffhomepage
path: root/configure.ml
diff options
context:
space:
mode:
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 3ce0b03d7..2292913d5 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 *)
@@ -851,9 +865,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, ... *)