Commit b5aa38ed authored by Gerd Stolpmann's avatar Gerd Stolpmann

using the same "topfind" file for both bytecode and native code

parent 9f05e4c2
......@@ -41,7 +41,7 @@ DYNLOAD_XOBJECTS = $(DYNLOAD_OBJECTS:.cmo=.cmx)
all: ocamlfind$(EXEC_SUFFIX) findlib.cma findlib_top.cma topfind num_top.cma \
findlib_dynload.cma
opt: ocamlfind_opt$(EXEC_SUFFIX) findlib.cmxa findlib_top.cmxa topfind_nat \
opt: ocamlfind_opt$(EXEC_SUFFIX) findlib.cmxa findlib_top.cmxa topfind \
findlib_dynload.cmxa
ocamlfind$(EXEC_SUFFIX): findlib.cma $(OCAMLFIND_OBJECTS)
......@@ -110,13 +110,6 @@ topfind: topfind_rd$(OCAML_REMOVE_DIRECTORY).p
$(TOP)/tools/patch '@SITELIB@' '$(OCAML_SITELIB)' \
>topfind
topfind_nat: topfind_nat.p
USE_CYGPATH="$(USE_CYGPATH)"; \
export USE_CYGPATH; \
cat topfind_nat.p | \
$(TOP)/tools/patch '@SITELIB@' '$(OCAML_SITELIB)' \
>topfind_nat
num_top.cma: $(NUMTOP_OBJECTS)
$(OCAMLC) -a -o num_top.cma $(NUMTOP_OBJECTS)
......@@ -129,8 +122,7 @@ install: all
mkdir -p "$(prefix)$(OCAML_SITELIB)/$(NAME)"
mkdir -p "$(prefix)$(OCAMLFIND_BIN)"
test $(INSTALL_TOPFIND) -eq 0 || cp topfind "$(prefix)$(OCAML_CORE_STDLIB)"
test $(INSTALL_TOPFIND) -eq 0 -o ! -f topfind_nat || cp topfind_nat "$(prefix)$(OCAML_CORE_STDLIB)"
files=`$(TOP)/tools/collect_files $(TOP)/Makefile.config findlib.cmi findlib.mli findlib.cma topfind.cmi topfind.mli fl_package_base.mli fl_package_base.cmi fl_metascanner.mli fl_metascanner.cmi fl_metatoken.cmi findlib_top.cma findlib.cmxa findlib.a findlib.cmxs findlib_dynload.cma findlib_dynload.cmxa findlib_dynload.a findlib_dynload.cmxs fl_dynload.mli fl_dynload.cmi META` && \
files=`$(TOP)/tools/collect_files $(TOP)/Makefile.config findlib.cmi findlib.mli findlib.cma findlib.cmxa findlib.a findlib.cmxs topfind.cmi topfind.mli fl_package_base.mli fl_package_base.cmi fl_metascanner.mli fl_metascanner.cmi fl_metatoken.cmi findlib_top.cma findlib_top.cmxa findlib_top.a findlib_top.cmxs findlib_dynload.cma findlib_dynload.cmxa findlib_dynload.a findlib_dynload.cmxs fl_dynload.mli fl_dynload.cmi META` && \
cp $$files "$(prefix)$(OCAML_SITELIB)/$(NAME)"
f="ocamlfind$(EXEC_SUFFIX)"; { test -f ocamlfind_opt$(EXEC_SUFFIX) && f="ocamlfind_opt$(EXEC_SUFFIX)"; }; \
cp $$f "$(prefix)$(OCAMLFIND_BIN)/ocamlfind$(EXEC_SUFFIX)"
......
(* $Id$ -*- tuareg -*- *)
(* For Ocaml-3.03 and up, so you can do: #use "topfind" and get a
* working findlib toploop.
*)
#directory "@SITELIB@/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
if not(exec_test "Topfind.reset;;") then (
Topdirs.dir_load Format.err_formatter "@SITELIB@/findlib/findlib.cmxs";
Topdirs.dir_load Format.err_formatter "@SITELIB@/findlib/findlib_top.cmxs";
);;
#remove_directory "+compiler-libs";;
(* Old: *)
(* #load "@SITELIB@/findlib/findlib.cma";; *)
(* #load "@SITELIB@/findlib/findlib_top.cma";; *)
(* The following is always executed. It is harmless if findlib was already
* initialized
*)
Topfind.add_predicates [ "native"; "toploop" ];
Topfind.don't_load ["findlib"];
Topfind.announce();;
......@@ -23,11 +23,16 @@ let exec_test s =
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 "@SITELIB@/findlib/findlib.cma";
Topdirs.dir_load Format.err_formatter "@SITELIB@/findlib/findlib_top.cma";
);;
Topdirs.dir_load Format.err_formatter ("@SITELIB@/findlib/findlib." ^ suffix);
Topdirs.dir_load Format.err_formatter ("@SITELIB@/findlib/findlib_top." ^ suffix);
);
;;
#remove_directory "+compiler-libs";;
......@@ -40,6 +45,11 @@ if not(exec_test "Topfind.reset;;") then (
* initialized
*)
Topfind.add_predicates [ "byte"; "toploop" ];
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();;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment