Skip to content

Commit bdefc26

Browse files
authored
Merge pull request xapi-project#331 from mseri/fix-xentoollog
configure.ml: More robust way to detect whether xentoollog needs linking
2 parents cfd009b + c150926 commit bdefc26

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

configure.ml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,26 @@ let output_file filename lines =
8585
List.iter (fun line -> Printf.fprintf oc "%s\n" line) lines;
8686
close_out oc
8787

88-
let cc c_program =
89-
let c_file = Filename.temp_file "configure" ".c" in
90-
let o_file = c_file ^ ".o" in
91-
output_file c_file c_program;
92-
let found = Sys.command (Printf.sprintf "cc -Werror -c %s -o %s 2>/dev/null" c_file o_file) = 0 in
93-
if Sys.file_exists c_file then Sys.remove c_file;
94-
if Sys.file_exists o_file then Sys.remove o_file;
95-
found
96-
97-
let check_domain_create_has_config_param () =
88+
let find_xentoollog verbose =
9889
let c_program = [
99-
"#include <stdlib.h>";
100-
"#include <xenctrl.h>";
101-
"#include <xenguest.h>";
102-
"int main(int argc, char *argv[]){";
103-
" xc_domain_create(0, 0, 0, 0, 0, 0);";
90+
"int main(int argc, const char *argv){";
10491
" return 0;";
10592
"}";
10693
] in
107-
let found = cc c_program in
108-
Printf.printf "Looking for config parameter on xc_domain_create: %s\n" (if found then "ok" else "missing");
94+
let c_file = Filename.temp_file "configure" ".c" in
95+
let exe_file = c_file ^ ".exe" in
96+
output_file c_file c_program;
97+
let found = Sys.command (Printf.sprintf "cc -Werror %s -lxentoollog -o %s %s" c_file exe_file (if verbose then "" else "2>/dev/null")) = 0 in
98+
if Sys.file_exists c_file then Sys.remove c_file;
99+
if Sys.file_exists exe_file then Sys.remove exe_file;
100+
Printf.printf "Looking for xentoollog: %s\n" (if found then "found" else "missing");
109101
found
110102

111103
let configure bindir sbindir libexecdir scriptsdir etcdir mandir =
112104
let xenctrl = find_ocamlfind false "xenctrl" in
113105
let xenlight = find_ocamlfind false "xenlight" in
114106
let xen45 = find_seriallist () in
115-
let xen_4_7 = check_domain_create_has_config_param () in
107+
let xentoollog = find_xentoollog false in
116108
let p = Printf.sprintf in
117109
List.iter print_endline
118110
[ "Configure with"
@@ -124,7 +116,7 @@ let configure bindir sbindir libexecdir scriptsdir etcdir mandir =
124116
; p "\tmandir=%s" mandir
125117
; p "\txenctrl=%b" xenctrl
126118
; p "\txenlight=%b" xenlight
127-
; p "\txentoollog=%b" xen_4_7
119+
; p "\txentoollog=%b" xentoollog
128120
; p "" (* new line *)
129121
];
130122

@@ -140,7 +132,7 @@ let configure bindir sbindir libexecdir scriptsdir etcdir mandir =
140132
Printf.sprintf "MANDIR=%s" mandir;
141133
Printf.sprintf "ENABLE_XEN=--%s-xen" (if xenctrl then "enable" else "disable");
142134
Printf.sprintf "ENABLE_XENLIGHT=--%s-xenlight" (if xenlight then "enable" else "disable");
143-
Printf.sprintf "ENABLE_XENTOOLLOG=--%s-xentoollog" (if not xen_4_7 then "disable" else "enable");
135+
Printf.sprintf "ENABLE_XENTOOLLOG=--%s-xentoollog" (if xentoollog then "enable" else "disable");
144136
] in
145137
output_file config_mk lines;
146138
(* Expand @LIBEXEC@ in udev rules *)

0 commit comments

Comments
 (0)