Permalink
Fetching contributors…
Cannot retrieve contributors at this time
87 lines (70 sloc) 1.97 KB
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";
];