- Options.ocamlc := ocamlfind (A"ocamlc");
- Options.ocamlopt := ocamlfind (A"ocamlopt");
- Options.ocamldep := ocamlfind (A"ocamldep");
- Options.ocamldoc := ocamlfind (A"ocamldoc");
- Options.ocamlmktop := ocamlfind (A"ocamlmktop");
-
- if not (List.mem "log" !Options.tags) then begin
- pp_macro_options @= [ A "-DNLOG" ];
- end;
- if (List.mem "profile" !Options.tags) then begin
- pp_macro_options @= [ A "-DPROFILE" ];
- native_compile_flags @= [A "-p" ];
- native_link_flags @= [ "-p" ];
- cxx_flags @= [ A "-pg" ];
- cxx_link_flags @= [ A "-pg" ];
- end;
-
- if (List.mem "debug" !Options.tags) then begin
- pp_macro_options @= [ A "-DDEBUG" ];
- cxx_flags @= [ A "-O0"; A "-g" ];
- cxx_link_flags @= [ A "-g" ];
- end
- else begin
- compile_flags @= [A "-noassert"];
- pp_macro_options @= [ A "-unsafe" ];
- native_compile_flags @= [ A "-inline"; A ocaml_inline ];
- cxx_flags @= [ A "-O3" ]
- end;
-
- let dir_path = Pathname.pwd / src_path in
- let dir = Pathname.readdir dir_path in
-
- Array.iter (fun entry ->
- if Pathname.check_extension entry "ml" then
- Depends.ocaml (src_path / entry)
- else if Pathname.check_extension entry "cpp" then
- Depends.cxx (src_path / entry)
- ) dir;
-
- | After_rules ->
- dep [ "link" ] cstub_lib;
- rule "c++: cpp & depends -> o" ~prod:"%.o" ~deps:[ "%.cpp" ] cxx_compile;
- let syntax_flags = S[ S (ppopt !pp_macro_options) ]
- in
- flag [ "ocaml"; "ocamldep"] syntax_flags;
- flag [ "ocaml"; "compile" ] (S[ A "-cc"; A cxx_cmd; S cxx_flags_for_ml ; syntax_flags; S !compile_flags ]);
- flag [ "ocaml"; "native"; "compile" ] (S !native_compile_flags);
- flag [ "ocaml"; "link" ]
- (S [ S link_flags ; A "-cc"; A cxx_cmd; S cxx_flags_for_ml; A "-cclib" ;
- Quote (S [ _S cstub_lib; S !cxx_link_flags]) ]);
- flag [ "ocaml"; "byte"; "link" ] (_S !byte_link_flags);
- flag [ "ocaml"; "native"; "link" ] (_S !native_link_flags);
- flag [ "c"; "ocamlmklib"] (A "-custom")