Release coccinelle-0.2.4rc6
[bpt/coccinelle.git] / ocaml / yes_prepare_ocamlcocci.ml
index a1ce3a2..8498189 100644 (file)
@@ -6,6 +6,12 @@ exception LinkFailure of string
 let ext = if Dynlink.is_native then ".cmxs" else ".cma"
 let has_ocamlfind = ref false
 
+let sysdir = 
+  let sysdircmd = !Flag.ocamlfind ^ " printconf stdlib" in
+  match Common.cmd_to_list sysdircmd with
+    [sysdir] -> sysdir
+  | _ -> raise (CompileFailure (sysdircmd ^" has failed"))
+
 let check_cmd cmd =
   let (_,stat) = Common.cmd_to_list_and_status cmd in
   match stat with
@@ -238,7 +244,9 @@ let dep_flag mlfile =
   let depcmd  = !Flag.ocamldep ^" -modules "^mlfile in
   match Common.cmd_to_list depcmd with
     [dep] -> parse_dep mlfile dep
-  | _ -> raise (CompileFailure ("Wrong dependencies for "^mlfile))
+  | err ->
+      List.iter (function x -> Common.pr2 (x^"\n")) err;
+      raise (CompileFailure ("Failed ocamldep for "^mlfile))
 
 let compile_bytecode_cmd flags mlfile =
   let obj = (Filename.chop_extension mlfile) ^ ".cmo" in
@@ -287,8 +295,8 @@ let load_file mlfile =
 (*   let linklibs = link_libs lklibs in *)
   let flags =
     Printf.sprintf
-    "-thread -g -dtypes -I /usr/lib/ocaml %s -I %s/ocaml -I %s/parsing_c -I %s/commons "
-      inc Config.path Config.path Config.path in
+    "-thread -g -dtypes -I %s %s -I %s/ocaml -I %s/parsing_c -I %s/commons "
+      sysdir inc Config.path Config.path Config.path in
   let (obj, cmd) =
     if Dynlink.is_native
     then compile_native_cmd flags mlfile