let prepare_libs cma_ext a_ext out build =
let out_no_ext = Pathname.remove_extension out in
let libs1 = List.union (libraries_of out_no_ext) (libs_of_use_lib (tags_of_pathname out)) in
let () = dprintf 10 "prepare_libs: %S -> %a" out pp_l libs1 in
let libs = List.map (fun x -> x-.-cma_ext) libs1 in
let libs2 = List.map (fun lib -> [lib-.-a_ext]) libs1 in
List.iter ignore_good (build libs2); libs