diff options
-rw-r--r-- | Changes | 4 | ||||
-rw-r--r-- | tools/ocamlmklib.ml | 29 |
2 files changed, 27 insertions, 6 deletions
@@ -82,6 +82,10 @@ OCamlbuild: - PR#6720: pass -g to C compilers when tag 'debug' is set (Peter Zotov, Gabriel Scherer) +Tools: +- PR#6641: add -g, -ocamlcflags, -ocamloptflags options to ocamlmklib + (Peter Zotov) + Bug fixes: - PR#5836, PR#6684: printing lazy values in ocamldebug may segfault (Gabriel Scherer) diff --git a/tools/ocamlmklib.ml b/tools/ocamlmklib.ml index 77ae57bec..23a273ec1 100644 --- a/tools/ocamlmklib.ml +++ b/tools/ocamlmklib.ml @@ -27,14 +27,17 @@ and caml_opts = ref [] (* -ccopt to pass to ocamlc, ocamlopt *) and dynlink = ref supports_shared_libraries and failsafe = ref false (* whether to fall back on static build only *) and c_libs = ref [] (* libs to pass to mksharedlib and ocamlc -cclib *) -and c_Lopts = ref [] (* options to pass to mksharedlib and ocamlc -cclib *) -and c_opts = ref [] (* options to pass to mksharedlib and ocamlc -ccopt *) +and c_Lopts = ref [] (* options to pass to mksharedlib and ocamlc -cclib *) +and c_opts = ref [] (* options to pass to mksharedlib and ocamlc -ccopt *) and ld_opts = ref [] (* options to pass only to the linker *) and ocamlc = ref (compiler_path "ocamlc") +and ocamlc_opts = ref [] (* options to pass only to ocamlc *) and ocamlopt = ref (compiler_path "ocamlopt") +and ocamlopt_opts = ref [] (* options to pass only to ocamlc *) and output = ref "a" (* Output name for OCaml part of library *) and output_c = ref "" (* Output name for C part of library *) and rpath = ref [] (* rpath options *) +and debug = ref false (* -g option *) and verbose = ref false let starts_with s pref = @@ -84,6 +87,8 @@ let parse_arguments argv = caml_opts := next_arg () :: "-I" :: !caml_opts else if s = "-failsafe" then failsafe := true + else if s = "-g" then + debug := true else if s = "-h" || s = "-help" || s = "--help" then raise (Bad_argument "") else if s = "-ldopt" then @@ -96,10 +101,14 @@ let parse_arguments argv = (c_Lopts := s :: !c_Lopts; let l = chop_prefix s "-L" in if not (Filename.is_relative l) then rpath := l :: !rpath) + else if s = "-ocamlcflags" then + ocamlc_opts := next_arg () :: !ocamlc_opts else if s = "-ocamlc" then ocamlc := next_arg () else if s = "-ocamlopt" then ocamlopt := next_arg () + else if s = "-ocamloptflags" then + ocamlopt_opts := next_arg () :: !ocamlopt_opts else if s = "-o" then output := next_arg() else if s = "-oc" then @@ -148,7 +157,8 @@ Usage: ocamlmklib [options] <.cmo|.cma|.cmx|.cmxa|.ml|.mli|.o|.a|.obj|.lib|\ \nOptions are:\ \n -cclib <lib> C library passed to ocamlc -a or ocamlopt -a only\ \n -ccopt <opt> C option passed to ocamlc -a or ocamlopt -a only\ -\n -custom disable dynamic loading\ +\n -custom Disable dynamic loading\ +\n -g Build with debug information\ \n -dllpath <dir> Add <dir> to the run-time search path for DLLs\ \n -F<dir> Specify a framework directory (MacOSX)\ \n -framework <name> Use framework <name> (MacOSX)\ @@ -162,7 +172,9 @@ Usage: ocamlmklib [options] <.cmo|.cma|.cmx|.cmxa|.ml|.mli|.o|.a|.obj|.lib|\ \n -l<lib> Specify a dependent C library\ \n -L<dir> Add <dir> to the path searched for C libraries\ \n -ocamlc <cmd> Use <cmd> in place of \"ocamlc\"\ +\n -ocamlcflags <opt> Pass <opt> to ocamlc\ \n -ocamlopt <cmd> Use <cmd> in place of \"ocamlopt\"\ +\n -ocamloptflags <opt> Pass <opt> to ocamlopt\ \n -o <name> Generated OCaml library is named <name>.cma or <name>.cmxa\ \n -oc <name> Generated C library is named dll<name>.so or lib<name>.a\ \n -rpath <dir> Same as -dllpath <dir>\ @@ -229,8 +241,9 @@ let build_libs () = if !c_objs <> [] then begin if !dynlink then begin let retcode = command - (Printf.sprintf "%s -o %s %s %s %s %s %s" + (Printf.sprintf "%s %s -o %s %s %s %s %s %s" mkdll + (if !debug then "-g" else "") (prepostfix "dll" !output_c ext_dll) (String.concat " " !c_objs) (String.concat " " !c_opts) @@ -248,9 +261,11 @@ let build_libs () = end; if !bytecode_objs <> [] then scommand - (sprintf "%s -a %s -o %s.cma %s %s -dllib -l%s -cclib -l%s %s %s %s %s" + (sprintf "%s -a %s %s %s -o %s.cma %s %s -dllib -l%s -cclib -l%s %s %s %s %s" (transl_path !ocamlc) + (if !debug then "-g" else "") (if !dynlink then "" else "-custom") + (String.concat " " !ocamlc_opts) !output (String.concat " " !caml_opts) (String.concat " " !bytecode_objs) @@ -262,8 +277,10 @@ let build_libs () = (String.concat " " !caml_libs)); if !native_objs <> [] then scommand - (sprintf "%s -a -o %s.cmxa %s %s -cclib -l%s %s %s %s %s" + (sprintf "%s -a %s %s -o %s.cmxa %s %s -cclib -l%s %s %s %s %s" (transl_path !ocamlopt) + (if !debug then "-g" else "") + (String.concat " " !ocamlopt_opts) !output (String.concat " " !caml_opts) (String.concat " " !native_objs) |