- let cmd = sprintf "%s c -I +camlp4 -I %s -package unix,camlp4.lib -pp 'camlp4o %s/pa_when.cmo' -c %s"
- Config.ocamlfind !libdir !libdir file in
+ let cmd =
+ if not Config.have_ocamlopt then
+ (* bytecode *)
+ sprintf "%s c -I +camlp4 -I %s -package unix,camlp4.lib -pp 'camlp4o %s/pa_when.cmo' -c %s"
+ Config.ocamlfind !libdir !libdir file
+ else (
+ (* native code *)
+ let base = Filename.chop_extension file in (* without .ml suffix *)
+ sprintf "%s opt -I +camlp4 -I %s -package unix,camlp4.lib -pp 'camlp4o %s/pa_when.cmo' -c %s &&\n%s opt -shared -linkall %s.cmx -o %s.cmxs"
+ Config.ocamlfind !libdir !libdir file
+ Config.ocamlfind base base
+ ) in