Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions patches/ocaml-system/gen_ocaml_config.ml.in.after-5.4.0
Original file line number Diff line number Diff line change
@@ -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