let link_flags f l =
let pkgs = topological_closure l in
let locations = List.fold_left begin fun acc p ->
SSet.add p.location acc
end SSet.empty pkgs in
let flags = [] in
(* includes *)
let flags =
List.fold_left begin fun acc l ->
add_atom (P l) (add_atom (A "-I") acc)
end flags (SSet.elements locations)
in
(* special link options *)
let flags =
List.fold_left begin fun acc x ->
add_atom (A x.link_options) acc
end flags pkgs
in
(* archives *)
let flags =
List.fold_left begin fun acc x ->
add_atom (A (f x)) acc
end flags pkgs
in
S (List.rev flags)