forked from xapi-project/xen-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ml
82 lines (70 loc) · 3.96 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
let config_mk = "config.mk"
(* Configure script *)
open Cmdliner
let dir name default docv doc =
let doc = Printf.sprintf "Set the directory for installing %s" doc in
Arg.(value & opt string default & info [name] ~docv ~doc)
let path name default docv doc =
let doc = Printf.sprintf "Set the path for %s" doc in
Arg.(value & opt string default & info [name] ~docv ~doc)
let disable_tests =
let doc = "Disable the unit tests" in
Arg.(value & flag & info [ "disable-tests" ] ~doc)
let disable_warn_error =
let doc = "Disable -warn-error (default is enabled for development)" in
Arg.(value & flag & info [ "disable-warn-error" ] ~doc)
let varpatchdir = dir "varpatchdir" "/var/patch" "VARPATCHDIR" "hotfixes"
let etcdir = dir "etcdir" "/etc/xensource" "ETCDIR" "configuration files"
let optdir = dir "optdir" "/opt/xensource" "OPTDIR" "system files"
let plugindir = dir "plugindir" "/etc/xapi.d/plugins" "PLUGINDIR" "xapi plugins"
let hooksdir = dir "hooksdir" "/etc/xapi.d" "HOOKSDIR" "hook scripts"
let inventory = path "inventory" "/etc/xensource-inventory" "INVENTORY" "the inventory file"
let xapiconf = dir "xapiconf" "/etc/xapi.conf" "XAPICONF" "xapi master config file"
let libexecdir = dir "libexecdir" "/opt/xensource/libexec" "LIBEXECDIR" "utility binaries"
let scriptsdir = dir "scriptsdir" "/etc/xensource/scripts" "SCRIPTSDIR" "utility scripts"
let sharedir = dir "sharedir" "/opt/xensource" "SHAREDIR" "shared binary files"
let webdir = dir "webdir" "/opt/xensource/www" "WEBDIR" "html files"
let xhadir = dir "xhadir" "/opt/xensource/xha" "XHADIR" "HA daemon"
let bindir = dir "bindir" "/opt/xensource/bin" "BINDIR" "binaries"
let sbindir = dir "sbindir" "/opt/xensource/bin" "BINDIR" "system binaries"
let udevdir = dir "udevdir" "/etc/udev" "UDEVDIR" "udev scripts"
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 disable_tests disable_warn_error varpatchdir etcdir optdir plugindir hooksdir inventory xapiconf libexecdir scriptsdir sharedir webdir xhadir bindir sbindir udevdir =
Printf.printf "Configuring with the following params:\n\tdisable_tests=%b\n\tdisable_warn_error=%b\n\tvarpatchdir=%s\n\tetcdir=%s\n\toptdir=%s\n\tplugindir=%s\n\thooksdir=%s\n\tinventory=%s\n\txapiconf=%s\n\tlibexecdir=%s\n\tscriptsdir=%s\n\tsharedir=%s\n\twebdir=%s\n\txhadir=%s\n\tbindir=%s\n\tsbindir=%s\n\tudevdir=%s\n\n" disable_tests disable_warn_error varpatchdir etcdir optdir plugindir hooksdir inventory xapiconf libexecdir scriptsdir sharedir webdir xhadir bindir sbindir udevdir;
(* Write config.mk *)
let lines =
[ "# Warning - this file is autogenerated by the configure script";
"# Do not edit";
Printf.sprintf "DISABLE_TESTS=%b" disable_tests;
Printf.sprintf "DISABLE_WARN_ERROR=%b" disable_warn_error;
Printf.sprintf "VARPATCHDIR=%s" varpatchdir;
Printf.sprintf "ETCDIR=%s" etcdir;
Printf.sprintf "OPTDIR=%s" optdir;
Printf.sprintf "PLUGINDIR=%s" plugindir;
Printf.sprintf "HOOKSDIR=%s" hooksdir;
Printf.sprintf "INVENTORY=%s" inventory;
Printf.sprintf "XAPICONF=%s" xapiconf;
Printf.sprintf "LIBEXECDIR=%s" libexecdir;
Printf.sprintf "SCRIPTSDIR=%s" scriptsdir;
Printf.sprintf "SHAREDIR=%s" sharedir;
Printf.sprintf "WEBDIR=%s" webdir;
Printf.sprintf "XHADIR=%s" xhadir;
Printf.sprintf "BINDIR=%s" bindir;
Printf.sprintf "SBINDIR=%s" sbindir;
Printf.sprintf "UDEVDIR=%s" udevdir
] in
output_file config_mk lines
let configure_t = Term.(pure configure $ disable_tests $ disable_warn_error $ varpatchdir $ etcdir $ optdir $ plugindir $ hooksdir $ inventory $ xapiconf $ libexecdir $ scriptsdir $ sharedir $ webdir $ xhadir $ bindir $ sbindir $ udevdir )
let () =
match
Term.eval (configure_t, info)
with
| `Error _ -> exit 1
| _ -> exit 0