1 (**************************************************************************)
2 (* *)
3 (* OCaml *)
4 (* *)
5 (* Sebastien Hinderer, projet Gallium, INRIA Paris *)
6 (* *)
7 (* Copyright 2018 Institut National de Recherche en Informatique et *)
8 (* en Automatique. *)
9 (* *)
10 (* All rights reserved. This file is distributed under the terms of *)
11 (* the GNU Lesser General Public License version 2.1, with the *)
12 (* special exception on linking described in the file LICENSE. *)
13 (* *)
14 (**************************************************************************)
15
16 (* Flags used in OCaml commands *)
17
18 let stdlib ocamlsrcdir =
19 let stdlib_path = Ocaml_directories.stdlib ocamlsrcdir in
20 "-nostdlib -I " ^ stdlib_path
21
22 let include_toplevel_directory ocamlsrcdir =
23 "-I " ^ (Ocaml_directories.toplevel ocamlsrcdir)
24
25 let c_includes ocamlsrcdir =
26 let dir = Ocaml_directories.runtime ocamlsrcdir in
27 "-ccopt -I" ^ dir
28
29 let runtime_variant_flags () = match Ocaml_files.runtime_variant() with
30 | Ocaml_files.Normal -> ""
31 | Ocaml_files.Debug -> " -runtime-variant d"
32 | Ocaml_files.Instrumented -> " -runtime-variant i"
33
34 let runtime_flags ocamlsrcdir env backend c_files =
35 let runtime_library_flags = "-I " ^
36 (Ocaml_directories.runtime ocamlsrcdir) in
37 let rt_flags = match backend with
38 | Ocaml_backends.Native -> runtime_variant_flags ()
39 | Ocaml_backends.Bytecode ->
40 begin
41 if c_files then begin (* custom mode *)
42 "-custom " ^ (runtime_variant_flags ())
43 end else begin (* non-custom mode *)
44 let use_runtime =
45 Environments.lookup_as_bool Ocaml_variables.use_runtime env
46 in
47 if use_runtime = Some false
48 then ""
49 else "-use-runtime " ^ (Ocaml_files.ocamlrun ocamlsrcdir)
50 end
51 end in
52 rt_flags ^ " " ^ runtime_library_flags
53
54 let toplevel_default_flags = "-noinit -no-version -noprompt"
55
56 let ocamldebug_default_flags ocamlsrcdir =
57 "-no-version -no-prompt -no-time -no-breakpoint-message " ^
58 ("-I " ^ (Ocaml_directories.stdlib ocamlsrcdir) ^ " ") ^
59 ("-topdirs-path " ^ (Ocaml_directories.toplevel ocamlsrcdir))
60
61 let ocamlobjinfo_default_flags = "-null-crc"
62