let prepare_compile build ml =
  let dir = Pathname.dirname ml in
  let include_dirs = Pathname.include_dirs_of dir in
  let modules = path_dependencies_of ml in
  let results =
    build (List.map (fun (_, x) -> expand_module include_dirs x ["cmi"]) modules) in
  List.iter2 begin fun (mandatory, name) res ->
    match mandatory, res with
    | _, Good _ -> ()
    | `mandatory, Bad exn ->
        if !Options.ignore_auto then
          dprintf 3 "Warning: Failed to build the module %s requested by ocamldep" name
        else raise exn
    | `just_try, Bad _ -> ()
  end modules results