summaryrefslogtreecommitdiff
path: root/tools/ocamlmklib.mlp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ocamlmklib.mlp')
-rw-r--r--tools/ocamlmklib.mlp57
1 files changed, 36 insertions, 21 deletions
diff --git a/tools/ocamlmklib.mlp b/tools/ocamlmklib.mlp
index 3fcc1526fb..39aac11ff1 100644
--- a/tools/ocamlmklib.mlp
+++ b/tools/ocamlmklib.mlp
@@ -16,8 +16,8 @@ open Printf
open Myocamlbuild_config
let bytecode_objs = ref [] (* .cmo,.cma,.ml,.mli files to pass to jocamlc *)
-and native_objs = ref [] (* .cmx,.cmxa,.ml,.mli files to pass to jocamlopt *)
-and c_objs = ref [] (* .o, .a, .obj, .libfiles to pass to mksharedlib and ar *)
+and native_objs = ref [] (* .cmx,.cmxa,.ml,.mli files to pass to jocamlopt *)
+and c_objs = ref [] (* .o, .a, .obj, .libfiles to pass to mksharedlib and ar *)
and caml_libs = ref [] (* -cclib to pass to jocamlc, jocamlopt *)
and caml_opts = ref [] (* -ccopt to pass to jocamlc, jocamlopt *)
@@ -31,7 +31,6 @@ and jocamlopt = ref (Filename.concat bindir "jocamlopt")
and output = ref "a" (* Output name for Caml part of library *)
and output_c = ref "" (* Output name for C part of library *)
and rpath = ref [] (* rpath options *)
-and implib = ref "" (* windows implib flag *)
and verbose = ref false
let starts_with s pref =
@@ -64,7 +63,7 @@ let parse_arguments argv =
else if ends_with s ".ml" || ends_with s ".mli" then
(bytecode_objs := s :: !bytecode_objs;
native_objs := s :: !native_objs)
- else if List.exists (ends_with s) [".o"; ".a"; ".obj"; ".lib"] then
+ else if List.exists (ends_with s) [".o"; ".a"; ".obj"; ".lib"; ".dll"] then
c_objs := s :: !c_objs
else if s = "-cclib" then
caml_libs := next_arg () :: "-cclib" :: !caml_libs
@@ -72,13 +71,11 @@ let parse_arguments argv =
caml_opts := next_arg () :: "-ccopt" :: !caml_opts
else if s = "-custom" then
dynlink := false
- else if s = "-implib" then
- implib := next_arg ()
else if s = "-I" then
caml_opts := next_arg () :: "-I" :: !caml_opts
else if s = "-failsafe" then
failsafe := true
- else if s = "-h" || s = "-help" then
+ else if s = "-h" || s = "-help" || s = "--help" then
raise (Bad_argument "")
else if s = "-ldopt" then
ld_opts := next_arg () :: !ld_opts
@@ -129,15 +126,23 @@ let parse_arguments argv =
(fun r -> r := List.rev !r)
[ bytecode_objs; native_objs; c_objs; caml_libs; caml_opts;
c_libs; c_objs; c_opts; ld_opts; rpath ];
+ (* On retourne deux fois c_objs ?? -- AF *)
+
if !output_c = "" then output_c := !output
let usage = "\
-Usage: jocamlmklib [options] <.cmo|.cma|.cmx|.cmxa|.ml|.mli|.o|.a|.obj|.lib files>
+Usage: jocamlmklib [options] <.cmo|.cma|.cmx|.cmxa|.ml|.mli|.o|.a|.obj|.lib|.dll files>
+
Options are:
-cclib <lib> C library passed to jocamlc -a or jocamlopt -a only
-ccopt <opt> C option passed to jocamlc -a or jocamlopt -a only
-custom disable dynamic loading
-dllpath <dir> Add <dir> to the run-time search path for DLLs
+ -F<dir> Specify a framework directory (MacOSX)
+ -framework <name> Use framework <name> (MacOSX)
+ -help Print this help message and exit
+ --help Same as -help
+ -h Same as -help
-I <dir> Add <dir> to the path searched for Caml object files
-jocamlc <cmd> Use <cmd> in place of \"jocamlc\"
-jocamlopt <cmd> Use <cmd> in place of \"jocamlopt\"
@@ -153,12 +158,11 @@ Options are:
-rpath <dir> Same as -dllpath <dir>
-R<dir> Same as -rpath
-verbose Print commands before executing them
+ -v same as -verbose
+ -version Print version and exit
-Wl,-rpath,<dir> Same as -dllpath <dir>
-Wl,-rpath -Wl,<dir> Same as -dllpath <dir>
-Wl,-R<dir> Same as -dllpath <dir>
- -F<dir> Specify a framework directory (MacOSX)
- -framework <name> Use framework <name> (MacOSX)
- -version Print version and exit
"
let command cmd =
@@ -197,18 +201,29 @@ let prepostfix pre name post =
Filename.concat dir (pre ^ base ^ post)
;;
+let transl_path s =
+ match Sys.os_type with
+ | "Win32" ->
+ let rec aux i =
+ if i = String.length s || s.[i] = ' ' then s
+ else (if s.[i] = '/' then s.[i] <- '\\'; aux (i + 1))
+ in aux 0
+ | _ -> s
+
let build_libs () =
if !c_objs <> [] then begin
if !dynlink then begin
let retcode = command
- (mkdll (prepostfix "dll" !output_c ext_dll)
- !implib
- (sprintf "%s %s %s %s %s"
- (String.concat " " !c_objs)
- (String.concat " " !c_opts)
- (String.concat " " !ld_opts)
- (make_rpath mksharedlibrpath)
- (String.concat " " !c_libs)) "") in
+ (Printf.sprintf "%s -o %s %s %s %s %s %s"
+ mkdll
+ (prepostfix "dll" !output_c ext_dll)
+ (String.concat " " !c_objs)
+ (String.concat " " !c_opts)
+ (String.concat " " !ld_opts)
+ (make_rpath mksharedlibrpath)
+ (String.concat " " !c_libs)
+ )
+ in
if retcode <> 0 then if !failsafe then dynlink := false else exit 2
end;
safe_remove (prepostfix "lib" !output_c ext_lib);
@@ -219,7 +234,7 @@ let build_libs () =
if !bytecode_objs <> [] then
scommand
(sprintf "%s -a %s -o %s.cma %s %s -dllib -l%s -cclib -l%s %s %s %s %s"
- !jocamlc
+ (transl_path !jocamlc)
(if !dynlink then "" else "-custom")
!output
(String.concat " " !caml_opts)
@@ -233,7 +248,7 @@ let build_libs () =
if !native_objs <> [] then
scommand
(sprintf "%s -a -o %s.cmxa %s %s -cclib -l%s %s %s %s %s"
- !jocamlopt
+ (transl_path !jocamlopt)
!output
(String.concat " " !caml_opts)
(String.concat " " !native_objs)