Permalink
Browse files

Install compiler internals (as libraries + compiled interfaces + star…

…t modules)

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12469 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information...
xleroy
xleroy committed May 17, 2012
1 parent df15ee8 commit 13fc3224d3ba6f8e33f4091d34ecf36012156272
Showing with 101 additions and 69 deletions.
  1. +96 −65 Makefile
  2. +1 −1 _tags
  3. +2 −1 asmrun/Makefile
  4. +1 −1 tools/ocamlmktop.ml
  5. +1 −1 tools/ocamlmktop.tpl
View
161 Makefile
@@ -41,8 +41,6 @@ UTILS=utils/misc.cmo utils/tbl.cmo utils/config.cmo \
utils/clflags.cmo utils/terminfo.cmo utils/ccomp.cmo utils/warnings.cmo \
utils/consistbl.cmo
-OPTUTILS=$(UTILS)
-
PARSING=parsing/location.cmo parsing/longident.cmo \
parsing/syntaxerr.cmo parsing/parser.cmo \
parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo
@@ -64,12 +62,16 @@ COMP=bytecomp/lambda.cmo bytecomp/printlambda.cmo \
bytecomp/typeopt.cmo bytecomp/switch.cmo bytecomp/matching.cmo \
bytecomp/translobj.cmo bytecomp/translcore.cmo \
bytecomp/translclass.cmo bytecomp/translmod.cmo \
- bytecomp/simplif.cmo bytecomp/runtimedef.cmo
+ bytecomp/simplif.cmo bytecomp/runtimedef.cmo \
+ driver/pparse.cmo driver/main_args.cmo
+
+COMMON=$(UTILS) $(PARSING) $(TYPING) $(COMP)
BYTECOMP=bytecomp/meta.cmo bytecomp/instruct.cmo bytecomp/bytegen.cmo \
bytecomp/printinstr.cmo bytecomp/opcodes.cmo bytecomp/emitcode.cmo \
bytecomp/bytesections.cmo bytecomp/dll.cmo bytecomp/symtable.cmo \
- bytecomp/bytelink.cmo bytecomp/bytelibrarian.cmo bytecomp/bytepackager.cmo
+ bytecomp/bytelink.cmo bytecomp/bytelibrarian.cmo bytecomp/bytepackager.cmo \
+ driver/errors.cmo driver/compile.cmo
ASMCOMP=asmcomp/arch.cmo asmcomp/debuginfo.cmo \
asmcomp/cmm.cmo asmcomp/printcmm.cmo \
@@ -84,42 +86,22 @@ ASMCOMP=asmcomp/arch.cmo asmcomp/debuginfo.cmo \
asmcomp/printlinear.cmo asmcomp/linearize.cmo \
asmcomp/schedgen.cmo asmcomp/scheduling.cmo \
asmcomp/emitaux.cmo asmcomp/emit.cmo asmcomp/asmgen.cmo \
- asmcomp/asmlink.cmo asmcomp/asmlibrarian.cmo asmcomp/asmpackager.cmo
-
-DRIVER=driver/pparse.cmo driver/errors.cmo driver/compile.cmo \
- driver/main_args.cmo driver/main.cmo
-
-OPTDRIVER= driver/pparse.cmo driver/opterrors.cmo driver/optcompile.cmo \
- driver/main_args.cmo driver/optmain.cmo
+ asmcomp/asmlink.cmo asmcomp/asmlibrarian.cmo asmcomp/asmpackager.cmo \
+ driver/opterrors.cmo driver/optcompile.cmo
-TOPLEVEL=driver/pparse.cmo driver/errors.cmo driver/compile.cmo \
- driver/main_args.cmo toplevel/genprintval.cmo toplevel/toploop.cmo \
+TOPLEVEL=toplevel/genprintval.cmo toplevel/toploop.cmo \
toplevel/trace.cmo toplevel/topdirs.cmo toplevel/topmain.cmo
-TOPLEVELLIB=toplevel/toplevellib.cma
-TOPLEVELSTART=toplevel/topstart.cmo
-
-COMPOBJS=$(UTILS) $(PARSING) $(TYPING) $(COMP) $(BYTECOMP) $(DRIVER)
+BYTESTART=driver/main.cmo
-TOPLIB=$(UTILS) $(PARSING) $(TYPING) $(COMP) $(BYTECOMP) $(TOPLEVEL)
+OPTSTART=driver/optmain.cmo
-TOPOBJS=$(TOPLEVELLIB) $(TOPLEVELSTART)
+TOPLEVELSTART=toplevel/topstart.cmo
-NATTOPOBJS=$(OPTUTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) \
- driver/pparse.cmo driver/opterrors.cmo driver/optcompile.cmo \
- driver/main_args.cmo \
+NATTOPOBJS=$(UTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) \
toplevel/genprintval.cmo toplevel/opttoploop.cmo toplevel/opttopdirs.cmo \
toplevel/opttopmain.cmo toplevel/opttopstart.cmo
-OPTOBJS=$(OPTUTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) $(OPTDRIVER)
-
-EXPUNGEOBJS=utils/misc.cmo utils/tbl.cmo \
- utils/config.cmo utils/clflags.cmo \
- typing/ident.cmo typing/path.cmo typing/types.cmo typing/btype.cmo \
- utils/warnings.cmo parsing/location.cmo \
- typing/predef.cmo bytecomp/runtimedef.cmo bytecomp/bytesections.cmo \
- bytecomp/dll.cmo bytecomp/meta.cmo bytecomp/symtable.cmo toplevel/expunge.cmo
-
PERVASIVES=$(STDLIB_MODULES) outcometree topdirs toploop
# For users who don't read the INSTALL file
@@ -276,10 +258,14 @@ base.opt: checkstack runtime core ocaml opt-core ocamlc.opt otherlibraries \
otherlibrariesopt
# Installation
+
+COMPLIBDIR=$(LIBDIR)/compiler-libs
+
install:
if test -d $(BINDIR); then : ; else $(MKDIR) $(BINDIR); fi
if test -d $(LIBDIR); then : ; else $(MKDIR) $(LIBDIR); fi
if test -d $(STUBLIBDIR); then : ; else $(MKDIR) $(STUBLIBDIR); fi
+ if test -d $(COMPLIBDIR); then : ; else $(MKDIR) $(COMPLIBDIR); fi
if test -d $(MANDIR)/man$(MANEXT); then : ; \
else $(MKDIR) $(MANDIR)/man$(MANEXT); fi
cp VERSION $(LIBDIR)/
@@ -292,12 +278,9 @@ install:
cd stdlib; $(MAKE) install
cp lex/ocamllex $(BINDIR)/ocamllex$(EXE)
cp yacc/ocamlyacc$(EXE) $(BINDIR)/ocamlyacc$(EXE)
- cp toplevel/toplevellib.cma $(LIBDIR)/toplevellib.cma
+ cp utils/*.cmi parsing/*.cmi typing/*.cmi bytecomp/*.cmi driver/*.cmi toplevel/*.cmi $(COMPLIBDIR)
+ cp compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma compilerlibs/ocamltoplevel.cma $(BYTESTART) $(TOPLEVELSTART) $(COMPLIBDIR)
cp expunge $(LIBDIR)/expunge$(EXE)
- cp typing/outcometree.cmi typing/outcometree.mli $(LIBDIR)
- cp toplevel/topstart.cmo $(LIBDIR)
- cp toplevel/toploop.cmi toplevel/topdirs.cmi toplevel/topmain.cmi \
- $(LIBDIR)
cd tools; $(MAKE) install
-cd man; $(MAKE) install
for i in $(OTHERLIBRARIES); do \
@@ -316,33 +299,58 @@ installopt:
cd asmrun; $(MAKE) install
cp ocamlopt $(BINDIR)/ocamlopt$(EXE)
cd stdlib; $(MAKE) installopt
+ cp asmcomp/*.cmi $(COMPLIBDIR)
+ cp compilerlibs/ocamloptcomp.cma $(OPTSTART) $(COMPLIBDIR)
cd ocamldoc; $(MAKE) installopt
for i in $(OTHERLIBRARIES); \
do (cd otherlibs/$$i; $(MAKE) installopt) || exit $$?; done
- if test -f ocamlc.opt; \
- then cp ocamlc.opt $(BINDIR)/ocamlc.opt$(EXE); else :; fi
- if test -f ocamlopt.opt; \
- then cp ocamlopt.opt $(BINDIR)/ocamlopt.opt$(EXE); else :; fi
- if test -f lex/ocamllex.opt; \
- then cp lex/ocamllex.opt $(BINDIR)/ocamllex.opt$(EXE); else :; fi
+ if test -f ocamlopt.opt ; then $(MAKE) installoptopt; fi
+
+installoptopt:
+ cp ocamlc.opt $(BINDIR)/ocamlc.opt$(EXE)
+ cp ocamlopt.opt $(BINDIR)/ocamlopt.opt$(EXE)
+ cp lex/ocamllex.opt $(BINDIR)/ocamllex.opt$(EXE)
+ cp compilerlibs/ocamlcommon.cmxa compilerlibs/ocamlcommon.a \
+ compilerlibs/ocamlbytecomp.cmxa compilerlibs/ocamlbytecomp.a \
+ compilerlibs/ocamloptcomp.cma compilerlibs/ocamloptcomp.a \
+ $(BYTESTART:.cmo=.cmx) $(BYTESTART:.cmo=.o) \
+ $(OPTSTART:.cmo=.cmx) $(OPTSTART:.cmo=.o) \
+ $(COMPLIBDIR)
+ cd $(COMPLIBDIR) && $(RANLIB) ocamlcommon.a ocamlbytecomp.a ocamloptcomp.a
clean:: partialclean
-# The compiler
+# Shared parts of the system
+
+compilerlibs/ocamlcommon.cma: $(COMMON)
+ $(CAMLC) -a -o $@ $(COMMON)
+partialclean::
+ rm -f compilerlibs/ocamlcommon.cma
+
+# The bytecode compiler
+
+compilerlibs/ocamlbytecomp.cma: $(BYTECOMP)
+ $(CAMLC) -a -o $@ $(BYTECOMP)
+partialclean::
+ rm -f compilerlibs/ocamlbytecomp.cma
-ocamlc: $(COMPOBJS)
- $(CAMLC) $(LINKFLAGS) -o ocamlc $(COMPOBJS)
+ocamlc: compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma $(BYTESTART)
+ $(CAMLC) $(LINKFLAGS) -o ocamlc \
+ compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma $(BYTESTART)
@sed -e 's|@compiler@|$$topdir/boot/ocamlrun $$topdir/ocamlc|' \
driver/ocamlcomp.sh.in > ocamlcomp.sh
@chmod +x ocamlcomp.sh
-partialclean::
- rm -f ocamlc ocamlcomp.sh
-
# The native-code compiler
-ocamlopt: $(OPTOBJS)
- $(CAMLC) $(LINKFLAGS) -o ocamlopt $(OPTOBJS)
+compilerlibs/ocamloptcomp.cma: $(ASMCOMP)
+ $(CAMLC) -a -o $@ $(ASMCOMP)
+partialclean::
+ rm -f compilerlibs/ocamloptcomp.cma
+
+ocamlopt: compilerlibs/ocamlcommon.cma compilerlibs/ocamloptcomp.cma $(OPTSTART)
+ $(CAMLC) $(LINKFLAGS) -o ocamlopt \
+ compilerlibs/ocamlcommon.cma compilerlibs/ocamloptcomp.cma $(OPTSTART)
@sed -e 's|@compiler@|$$topdir/boot/ocamlrun $$topdir/ocamlopt|' \
driver/ocamlcomp.sh.in > ocamlcompopt.sh
@chmod +x ocamlcompopt.sh
@@ -352,16 +360,20 @@ partialclean::
# The toplevel
-ocaml: $(TOPOBJS) expunge
- $(CAMLC) $(LINKFLAGS) -linkall -o ocaml.tmp $(TOPOBJS)
+compilerlibs/ocamltoplevel.cma: $(TOPLEVEL)
+ $(CAMLC) -a -o $@ $(TOPLEVEL)
+partialclean::
+ rm -f compilerlibs/ocamltoplevel.cma
+
+ocaml: compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma compilerlibs/ocamltoplevel.cma $(TOPLEVELSTART) expunge
+ $(CAMLC) $(LINKFLAGS) -linkall -o ocaml.tmp \
+ compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma \
+ compilerlibs/ocamltoplevel.cma $(TOPLEVELSTART)
- $(CAMLRUN) ./expunge ocaml.tmp ocaml $(PERVASIVES)
rm -f ocaml.tmp
-toplevel/toplevellib.cma: $(TOPLIB)
- $(CAMLC) -a -o $@ $(TOPLIB)
-
partialclean::
- rm -f ocaml toplevel/toplevellib.cma
+ rm -f ocaml
# The native toplevel
@@ -430,13 +442,24 @@ partialclean::
beforedepend:: parsing/lexer.ml
+# Shared parts of the system compiled with the native-code compiler
+
+compilerlibs/ocamlcommon.cmxa: $(COMMON:.cmo=.cmx)
+ $(CAMLOPT) -a -o $@ $(COMMON:.cmo=.cmx)
+partialclean::
+ rm -f compilerlibs/ocamlcommon.cmxa compilerlibs/ocamlcommon.a
+
# The bytecode compiler compiled with the native-code compiler
-ocamlc.opt: $(COMPOBJS:.cmo=.cmx)
- cd asmrun; $(MAKE) meta.o dynlink.o
+compilerlibs/ocamlbytecomp.cmxa: $(BYTECOMP:.cmo=.cmx)
+ $(CAMLOPT) -a -o $@ $(BYTECOMP:.cmo=.cmx)
+partialclean::
+ rm -f compilerlibs/ocamlbytecomp.cmxa compilerlibs/ocamlbytecomp.a
+
+ocamlc.opt: compilerlibs/ocamlcommon.cmxa compilerlibs/ocamlbytecomp.cmxa $(BYTESTART:.cmo=.cmx)
$(CAMLOPT) $(LINKFLAGS) -ccopt "$(BYTECCLINKOPTS)" -o ocamlc.opt \
- $(COMPOBJS:.cmo=.cmx) \
- asmrun/meta.o asmrun/dynlink.o -cclib "$(BYTECCLIBS)"
+ compilerlibs/ocamlcommon.cmxa compilerlibs/ocamlbytecomp.cmxa \
+ $(BYTESTART:.cmo=.cmx) -cclib "$(BYTECCLIBS)"
@sed -e 's|@compiler@|$$topdir/ocamlc.opt|' \
driver/ocamlcomp.sh.in > ocamlcomp.sh
@chmod +x ocamlcomp.sh
@@ -446,16 +469,23 @@ partialclean::
# The native-code compiler compiled with itself
-ocamlopt.opt: $(OPTOBJS:.cmo=.cmx)
- $(CAMLOPT) $(LINKFLAGS) -o ocamlopt.opt $(OPTOBJS:.cmo=.cmx)
+compilerlibs/ocamloptcomp.cmxa: $(ASMCOMP:.cmo=.cmx)
+ $(CAMLOPT) -a -o $@ $(ASMCOMP:.cmo=.cmx)
+partialclean::
+ rm -f compilerlibs/ocamloptcomp.cmxa compilerlibs/ocamloptcomp.a
+
+ocamlopt.opt: compilerlibs/ocamlcommon.cmxa compilerlibs/ocamloptcomp.cmxa $(OPTSTART:.cmo=.cmx)
+ $(CAMLOPT) $(LINKFLAGS) -o ocamlopt.opt \
+ compilerlibs/ocamlcommon.cmxa compilerlibs/ocamloptcomp.cmxa \
+ $(OPTSTART:.cmo=.cmx)
@sed -e 's|@compiler@|$$topdir/ocamlopt.opt|' \
driver/ocamlcomp.sh.in > ocamlcompopt.sh
@chmod +x ocamlcompopt.sh
partialclean::
rm -f ocamlopt.opt
-$(OPTOBJS:.cmo=.cmx): ocamlopt
+$(COMMON:.cmo=.cmx) $(BYTECOMP:.cmo=.cmx) $(ASMCOMP:.cmo=.cmx): ocamlopt
# The numeric opcodes
@@ -546,8 +576,9 @@ tools/cvt_emit: tools/cvt_emit.mll
# The "expunge" utility
-expunge: $(EXPUNGEOBJS)
- $(CAMLC) $(LINKFLAGS) -o expunge $(EXPUNGEOBJS)
+expunge: compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma toplevel/expunge.cmo
+ $(CAMLC) $(LINKFLAGS) -o expunge \
+ compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma toplevel/expunge.cmo
partialclean::
rm -f expunge
View
2 _tags
@@ -17,7 +17,7 @@ true: -traverse
# Traverse only these directories
<{bytecomp,driver,stdlib,tools,asmcomp,camlp4,ocamlbuild,toplevel,ocamldoc,typing,otherlibs,utils,debugger,lex,parsing,byterun,asmrun}/**>: traverse
-"boot" or "byterun" or "asmrun": not_hygienic
+"boot" or "byterun" or "asmrun" or "compilerlibs": not_hygienic
# These should not be required but it fails on *BSD and Windows...
"yacc" or "win32caml": not_hygienic
View
@@ -26,7 +26,8 @@ COBJS=startup.o main.o fail.o roots.o globroots.o signals.o signals_asm.o \
misc.o freelist.o major_gc.o minor_gc.o memory.o alloc.o compare.o ints.o \
floats.o str.o array.o io.o extern.o intern.o hash.o sys.o parsing.o \
gc_ctrl.o terminfo.o md5.o obj.o lexing.o printexc.o callback.o weak.o \
- compact.o finalise.o custom.o unix.o backtrace.o natdynlink.o debugger.o
+ compact.o finalise.o custom.o unix.o backtrace.o natdynlink.o debugger.o \
+ meta.o dynlink.o
ASMOBJS=$(ARCH).o
View
@@ -14,4 +14,4 @@
let _ =
let args = Ccomp.quote_files (List.tl (Array.to_list Sys.argv)) in
- exit(Sys.command("ocamlc -linkall toplevellib.cma " ^ args ^ " topstart.cmo"))
+ exit(Sys.command("ocamlc -I +compiler-libs -linkall ocamlcommon.cma ocamlbytecomp.cma ocamltoplevel.cma " ^ args ^ " topstart.cmo"))
View
@@ -13,4 +13,4 @@
# $Id$
-exec %%BINDIR%%/ocamlc -linkall toplevellib.cma "$@" topstart.cmo
+exec %%BINDIR%%/ocamlc -I +compiler-libs -linkall ocamlcommon.cma ocamlbytecomp.cma ocamltoplevel.cma "$@" topstart.cmo

0 comments on commit 13fc322

Please sign in to comment.