forked from BinaryAnalysisPlatform/bap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.ml.in
86 lines (70 loc) · 1.97 KB
/
setup.ml.in
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
83
84
85
86
let cxx () : unit =
BaseEnv.var_define
~hide:false
~dump:true
~cli:BaseEnv.CLIWith
~short_desc:(fun () -> "c++ compiler")
"cxx"
(fun () -> OASISFileUtil.which ~ctxt "c++") |>
definition_end
let cxx_flags () : unit =
BaseEnv.var_define
~hide:true
~dump:true
~short_desc:(fun () -> "c++ flags")
"cxxflags"
(fun () -> "-std=c++11 -fPIC -I$standard_library -I$libdir/bap -Ilib/bap_disasm") |>
definition_end
let cxx_libs () : unit =
BaseEnv.var_define
~hide:true
~dump:true
~cli:BaseEnv.CLIWith
~short_desc:(fun () -> "c++ library")
"cxxlibs"
(fun () -> if BaseEnv.var_get "system" = "macosx" then "-lc++" else "-lstdc++") |>
definition_end
let cc_optimization () : unit =
BaseEnv.var_define
~hide:false
~dump:true
~cli:BaseEnv.CLIWith
~short_desc:(fun () -> "C compiler optimization level")
"cc_optimization"
(fun () -> "-O2") |>
definition_end
let check =
let open OASISMessage in
let error msg = error ~ctxt msg; exit 1 in
List.iter (fun (causes,expected,message) ->
if List.for_all (fun (v,e) -> is_set_to v e) causes &&
List.exists is_undefined expected
then error message)
let install_headers hdrs =
InternalInstallPlugin.lib_hook :=
fun (cs, bs, lib, dirs) ->
match lib.OASISTypes.lib_findlib_name with
| Some "bap" -> (cs, bs, lib, dirs, hdrs)
| _ -> (cs, bs, lib, dirs, [])
let () =
Unix.putenv "OCAMLFIND_IGNORE_DUPS_IN" @@
BaseEnv.var_get "standard_library";
define [
cxx;
cxx_flags;
cxx_libs;
cc_optimization;
];
install_headers [
"lib/bap_disasm/disasm.hpp";
"lib/bap_disasm/disasm.h";
];
setup ();
check [
["llvm","true"], ["llvm_lib"],
" Failed to find llvm library, consider using --with-llvm-version
or --with-llvm-config command line options, to point me on a
correct version of LLVM. ";
["serialization", "true"], ["piqic"],
"Failed find piqic compiler";
];