(* -*- tuareg -*- *)
open Jbuild_plugin.V1
let graphics_exists =
  try
    match run_and_read_lines "ocamlfind query -a-format -predicates byte graphics" with
    | path :: _ -> Sys.file_exists path
    | _ -> false
  with _ -> false

let () =
  let jbuild =
    if graphics_exists
    then {|
(library
  (name graphics_js)
  (public_name js_of_ocaml-lwt.graphics)
  (synopsis "Graphics for js_of_ocaml.")
  (optional)
  (libraries js_of_ocaml js_of_ocaml-lwt lwt graphics)
  (preprocess (pps js_of_ocaml-ppx)))
|}
    else {||}
  in
  send jbuild
