Commit 9f05e4c2 authored by Gerd Stolpmann's avatar Gerd Stolpmann

Support for native toploop (ocamlnat)

parent f902fbd2
......@@ -27,6 +27,7 @@ OBJECTS = findlib_config.cmo fl_split.cmo fl_metatoken.cmo fl_meta.cmo \
TOBJECTS = topfind.cmo
XOBJECTS = $(OBJECTS:.cmo=.cmx)
TXOBJECTS = topfind.cmx
OCAMLFIND_OBJECTS = ocaml_args.cmo frontend.cmo
OCAMLFIND_XOBJECTS = ocaml_args.cmx frontend.cmx
......@@ -40,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 topfind \
opt: ocamlfind_opt$(EXEC_SUFFIX) findlib.cmxa findlib_top.cmxa topfind_nat \
findlib_dynload.cmxa
ocamlfind$(EXEC_SUFFIX): findlib.cma $(OCAMLFIND_OBJECTS)
......@@ -66,6 +67,12 @@ findlib.cmxa: $(XOBJECTS)
$(OCAMLOPT) -shared -o findlib.cmxs $(XOBJECTS); \
fi
findlib_top.cmxa: $(TXOBJECTS)
$(OCAMLOPT) -a -o findlib_top.cmxa $(TXOBJECTS)
if [ $(HAVE_NATDYNLINK) -gt 0 ]; then \
$(OCAMLOPT) -shared -o findlib_top.cmxs $(TXOBJECTS); \
fi
findlib_dynload.cma: $(DYNLOAD_OBJECTS)
$(OCAMLC) -a -o findlib_dynload.cma $(DYNLOAD_OBJECTS)
......@@ -103,6 +110,13 @@ 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)
......@@ -115,6 +129,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` && \
cp $$files "$(prefix)$(OCAML_SITELIB)/$(NAME)"
f="ocamlfind$(EXEC_SUFFIX)"; { test -f ocamlfind_opt$(EXEC_SUFFIX) && f="ocamlfind_opt$(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();;
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