/usr/lib/ocaml/topfind is in libfindlib-ocaml-dev 1.7.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | (* $Id$ -*- tuareg -*- *)
(* For Ocaml-3.03 and up, so you can do: #use "topfind" and get a
* working findlib toploop.
*)
#directory "/usr/lib/ocaml/findlib";;
(* OCaml-4.00 requires to have #directory before we load anything *)
#directory "+compiler-libs";;
(* For OCaml-4.00. This directory will be later removed from path *)
(* First test whether findlib_top is already loaded. If not, load it now.
* The test works by executing the toplevel phrase "Topfind.reset" and
* checking whether this causes an error.
*)
let exec_test s =
let l = Lexing.from_string s in
let ph = !Toploop.parse_toplevel_phrase l in
let fmt = Format.make_formatter (fun _ _ _ -> ()) (fun _ -> ()) in
try
Toploop.execute_phrase false fmt ph
with
_ -> false
in
let is_native =
(* one of the few observable differences... *)
Gc.((get()).stack_limit) = 0 in
let suffix =
if is_native then "cmxs" else "cma" in
if not(exec_test "Topfind.reset;;") then (
Topdirs.dir_load Format.err_formatter ("/usr/lib/ocaml/findlib/findlib." ^ suffix);
Topdirs.dir_load Format.err_formatter ("/usr/lib/ocaml/findlib/findlib_top." ^ suffix);
);
;;
#remove_directory "+compiler-libs";;
(* Old: *)
(* #load "/usr/lib/ocaml/findlib/findlib.cma";; *)
(* #load "/usr/lib/ocaml/findlib/findlib_top.cma";; *)
(* The following is always executed. It is harmless if findlib was already
* initialized
*)
let is_native =
(* one of the few observable differences... *)
Gc.((get()).stack_limit) = 0 in
let pred =
if is_native then "native" else "byte" in
Topfind.add_predicates [ pred; "toploop" ];
Topfind.don't_load ["findlib"];
Topfind.announce();;
|