Skip to content

Commit

Permalink
Fix build on Windows (#96).
Browse files Browse the repository at this point in the history
  • Loading branch information
dbuenzli committed Oct 16, 2024
1 parent fd77252 commit 44bce9b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ let lib_with_clib ~lib ~clib ~has_lib ~src_dir ~stublib =
let record_stub_lib = strf "record_%s" stublib in
let link_stub_archive = strf "link_%s_archive" stublib in
let stub_ar = ar (strf "%s/lib%s" src_dir stublib) in
let stub_l = match !Ocamlbuild_plugin.Options.ext_lib with
| "lib" (* Windows *) -> A (strf "dll%s.dll" stublib)
let static_stub_l = match !Ocamlbuild_plugin.Options.ext_lib with
| "lib" (* Windows *) -> A (strf "%s.lib" stublib)
| _ -> A (strf "-l%s" stublib)
in
let dynamic_stub_l = match !Ocamlbuild_plugin.Options.ext_lib with
| "lib" (* Windows *) -> A (strf "dll%s.dll" stublib)
| _ -> static_stub_l
in
let clib_l = pkg_config "libs-only-l" clib in
let clib_L = pkg_config "libs-only-L" clib in
let clib_cflags = ccopts @@ (A has_lib) :: pkg_config "cflags" clib in
let clib_cclibs = cclibs @@ stub_l :: clib_l in
let clib_cclibs = cclibs @@ static_stub_l :: clib_l in
let clib_ccopts = ccopts @@ clib_L in
begin
dep [record_stub_lib] [stub_ar];
Expand All @@ -45,7 +49,7 @@ let lib_with_clib ~lib ~clib ~has_lib ~src_dir ~stublib =
flag ["c"; "ocamlmklib"; use_clib] (S (clib_L @ clib_l));

flag ["link"; "ocaml"; "library"; "byte"; record_stub_lib]
(S (dllibs [stub_l] @ clib_ccopts @ clib_cclibs));
(S (dllibs [dynamic_stub_l] @ clib_ccopts @ clib_cclibs));

flag ["link"; "ocaml"; "library"; "native"; record_stub_lib]
(S (clib_ccopts @ clib_cclibs));
Expand Down

0 comments on commit 44bce9b

Please sign in to comment.