forked from xapi-project/message-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ml
executable file
·57 lines (47 loc) · 1.57 KB
/
configure.ml
1
2
3
4
5
6
7
8
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
let config_mk = "config.mk"
let find_ocamlfind verbose name =
let found =
try
let (_: string) = Findlib.package_property [] name "requires" in
true
with
| Not_found ->
(* property within the package could not be found *)
true
| Findlib.No_such_package(_,_ ) ->
false in
if verbose then Printf.fprintf stderr "querying for ocamlfind package %s: %s" name (if found then "ok" else "missing");
found
(* Configure script *)
open Cmdliner
let bindir =
let doc = "Set the directory for installing binaries" in
Arg.(value & opt string "/usr/bin" & info ["bindir"] ~docv:"BINDIR" ~doc)
let info =
let doc = "Configures a package" in
Term.info "configure" ~version:"0.1" ~doc
let output_file filename lines =
let oc = open_out filename in
let lines = List.map (fun line -> line ^ "\n") lines in
List.iter (output_string oc) lines;
close_out oc
let configure bindir =
Printf.printf "Configuring with:\n\tbindir=%s\n\n" bindir;
let async = find_ocamlfind false "async" in
let lwt = find_ocamlfind false "lwt" in
(* Write config.mk *)
let lines =
[ "# Warning - this file is autogenerated by the configure script";
"# Do not edit";
Printf.sprintf "BINDIR=%s" bindir;
Printf.sprintf "ASYNC=--%s-async" (if async then "enable" else "disable");
Printf.sprintf "LWT=--%s-lwt" (if lwt then "enable" else "disable");
] in
output_file config_mk lines
let configure_t = Term.(pure configure $ bindir)
let () =
match
Term.eval (configure_t, info)
with
| `Error _ -> exit 1
| _ -> exit 0