diff --git a/patches/ocaml-system/gen_ocaml_config.ml.in.after-5.4.0 b/patches/ocaml-system/gen_ocaml_config.ml.in.after-5.4.0 new file mode 100644 index 0000000..df80b1c --- /dev/null +++ b/patches/ocaml-system/gen_ocaml_config.ml.in.after-5.4.0 @@ -0,0 +1,34 @@ +let () = + let exe = ".exe" in + let ocamlc = + let (base, suffix) = + let s = Sys.executable_name in + if Filename.check_suffix s exe then + (Filename.chop_suffix s exe, exe) + else + (s, "") in + base ^ "c" ^ suffix in + let ocamlc_digest = Digest.to_hex (Digest.file ocamlc) in + let libdir = + if Sys.command (ocamlc^" -where > %{_:name}%.config") = 0 then + let ic = open_in "%{_:name}%.config" in + let r = input_line ic in + close_in ic; + Sys.remove "%{_:name}%.config"; + r + else + failwith "Bad return from 'ocamlc -where'" + in + let graphics = Filename.concat libdir "graphics.cmi" in + let graphics_digest = + if Sys.file_exists graphics then + Digest.to_hex (Digest.file graphics) + else + String.make 32 '0' + in + let oc = open_out "%{_:name}%.config" in + Printf.fprintf oc "opam-version: \"2.0\"\n\ + file-depends: [ [ %%S %%S ] [ %%S %%S ] ]\n\ + variables { path: %%S }\n" + ocamlc ocamlc_digest graphics graphics_digest (Filename.dirname ocamlc); + close_out oc