ocaml/Makefile.Mac

489 lines
14 KiB
Makefile
Raw Normal View History

#########################################################################
# #
# Objective Caml #
# #
# Damien Doligez, projet Para, INRIA Rocquencourt #
# #
# Copyright 1999 Institut National de Recherche en Informatique et #
# en Automatique. All rights reserved. This file is distributed #
# under the terms of the Q Public License version 1.0. #
# #
#########################################################################
# $Id$
# The main Makefile
MacVersion = "Mac{MAJOR}.{MINOR}.{BUGFIX}{STAGE}{REV}"
CAMLC = :boot:ocamlrun :boot:ocamlc -I :boot:
COMPFLAGS = {INCLUDES}
LINKFLAGS =
CAMLYACC = :boot:ocamlyacc
YACCFLAGS =
CAMLLEX = :boot:ocamlrun :boot:ocamllex
CAMLDEP = :boot:ocamlrun :tools:ocamldep
DEPFLAGS = {INCLUDES}
CAMLRUN = :byterun:ocamlrun
INCLUDES = -I :utils: -I :parsing: -I :typing: -I :bytecomp: <20>
-I :driver: -I :toplevel:
UTILS = :utils:misc.cmo :utils:tbl.cmo :utils:config.cmo <20>
:utils:clflags.cmo :utils:terminfo.cmo :utils:ccomp.cmo <20>
:utils:warnings.cmo
PARSING = :parsing:linenum.cmo :parsing:location.cmo :parsing:longident.cmo <20>
:parsing:syntaxerr.cmo :parsing:parser.cmo <20>
:parsing:lexer.cmo :parsing:parse.cmo :parsing:printast.cmo
TYPING = :typing:ident.cmo :typing:path.cmo <20>
:typing:primitive.cmo :typing:types.cmo <20>
:typing:btype.cmo <20>
:typing:subst.cmo :typing:predef.cmo <20>
:typing:datarepr.cmo :typing:env.cmo <20>
:typing:typedtree.cmo <20>
:typing:ctype.cmo :typing:printtyp.cmo <20>
:typing:includeclass.cmo <20>
:typing:mtype.cmo :typing:includecore.cmo <20>
:typing:includemod.cmo :typing:parmatch.cmo <20>
:typing:typetexp.cmo :typing:typecore.cmo <20>
:typing:typedecl.cmo :typing:typeclass.cmo <20>
:typing:typemod.cmo
COMP = :bytecomp:lambda.cmo :bytecomp:printlambda.cmo <20>
:bytecomp:typeopt.cmo :bytecomp:switch.cmo :bytecomp:matching.cmo <20>
:bytecomp:translobj.cmo :bytecomp:translcore.cmo <20>
:bytecomp:translclass.cmo :bytecomp:translmod.cmo <20>
:bytecomp:simplif.cmo :bytecomp:runtimedef.cmo
BYTECOMP = :bytecomp:meta.cmo :bytecomp:instruct.cmo :bytecomp:bytegen.cmo <20>
:bytecomp:printinstr.cmo :bytecomp:opcodes.cmo :bytecomp:emitcode.cmo <20>
:bytecomp:bytesections.cmo :bytecomp:dll.cmo <20>
:bytecomp:symtable.cmo :bytecomp:bytelibrarian.cmo :bytecomp:bytelink.cmo
DRIVER = :driver:errors.cmo :driver:compile.cmo :driver:main_args.cmo <20>
:driver:main.cmo
TOPLEVEL = :driver:errors.cmo :driver:compile.cmo <20>
:toplevel:genprintval.cmo :toplevel:toploop.cmo <20>
:toplevel:trace.cmo :toplevel:topdirs.cmo
TOPLEVELMAIN = :toplevel:topmain.cmo
COMPOBJS = {UTILS} {PARSING} {TYPING} {COMP} {BYTECOMP} {DRIVER}
TOPLIB = {UTILS} {PARSING} {TYPING} {COMP} {BYTECOMP} {TOPLEVEL}
EXPUNGEOBJS = :utils:misc.cmo :utils:tbl.cmo <20>
:utils:config.cmo :utils:clflags.cmo <20>
:typing:ident.cmo :typing:path.cmo <20>
:typing:types.cmo :typing:btype.cmo :typing:predef.cmo <20>
:bytecomp:runtimedef.cmo :bytecomp:bytesections.cmo <20>
:bytecomp:dll.cmo :bytecomp:symtable.cmo <20>
:toplevel:expunge.cmo
PERVASIVES = arg array buffer callback char digest filename format gc hashtbl <20>
lexing list map obj parsing pervasives printexc printf queue random <20>
set sort stack string stream sys oo genlex topdirs toploop weak lazy <20>
marshal int32 int64 nativeint outcometree
# Recompile the system using the bootstrap compiler
all <EFBFBD> runtime ocamlc ocamllex ocamlyacc ocamltools library ocaml <EFBFBD>
otherlibraries camlp4out maccaml
# The compilation of ocaml will fail if the runtime has changed.
# Never mind, just do make bootstrap to reach fixpoint again.
# Compile everything the first time
world <EFBFBD>
domake coldstart
domake all
# Complete bootstrapping cycle
bootstrap <EFBFBD>
# Save the original bootstrap compiler
domake backup
# Promote the new compiler but keep the old runtime
# This compiler runs on :boot:ocamlrun and produces bytecode for
# :byterun:ocamlrun
domake promote-cross
# Rebuild ocamlc and ocamllex (run on :byterun:ocamlrun)
domake partialclean
domake ocamlc ocamllex
# Rebuild the library (using :byterun:ocamlrun :ocamlc)
domake library-cross
# Promote the new compiler and the new runtime
domake promote
# Rebuild everything, including ocaml and the tools
domake partialclean
domake all
# Check if fixpoint reached
domake compare
LIBFILES = :stdlib.cma :std_exit.cmo :<3A>.cmi camlheader
# Start up the system from the distribution compiler
coldstart <EFBFBD>
directory :byterun; domake all; directory ::
duplicate -y :byterun:ocamlrun :boot:ocamlrun
directory :yacc; domake all; directory ::
duplicate -y :yacc:ocamlyacc :boot:ocamlyacc
directory :stdlib
domake -d COMPILER=::boot:ocamlc all
duplicate -y {LIBFILES} ::boot:
directory ::
# Build the core system: the minimum needed to make depend and bootstrap
core <EFBFBD> runtime ocamlc ocamllex ocamlyacc ocamltools library
# Save the current bootstrap compiler
backup <EFBFBD>
if `exists -d :boot:Saved:` == ""
newfolder :boot:Saved:
end
move :boot:Saved: :boot:Saved.prev:
newfolder :boot:Saved:
move :boot:Saved.prev: :boot:Saved:Saved.prev:
duplicate -y :boot:ocamlrun :boot:Saved:
move :boot:ocamlc :boot:ocamllex :boot:ocamlyacc :boot:Saved:
directory :boot; duplicate -y {LIBFILES} :Saved:; directory ::
# Promote the newly compiled system to the rank of cross compiler
# (Runs on the old runtime, produces code for the new runtime)
promote-cross <EFBFBD>
duplicate -y :ocamlc :boot:ocamlc
duplicate -y :lex:ocamllex :boot:ocamllex
duplicate -y :yacc:ocamlyacc :boot:ocamlyacc
directory :stdlib
duplicate -y {LIBFILES} ::boot: || set status 0
directory ::
# Promote the newly compiled system to the rank of bootstrap compiler
# (Runs on the new runtime, produces code for the new runtime)
promote <EFBFBD> promote-cross
duplicate -y :byterun:ocamlrun :boot:ocamlrun
clean <EFBFBD><EFBFBD>
delete -i :boot:<3A>.cm[aio] || set status 0
delete -i :boot:camlheader :boot:ocamlrun :boot:ocamlyacc
# Restore the saved bootstrap compiler if a problem arises
restore <EFBFBD>
move -y :boot:Saved:<3A> :boot:
delete -y :boot:Saved:
move -y :boot:Saved.prev: :boot:Saved:
# Check if fixpoint reached
compare <EFBFBD>
set exit 0
equal -q :boot:ocamlc :ocamlc && equal -q :boot:ocamllex :lex:ocamllex
if {status}
echo "<22>nFixpoint not reached, try one more bootstrapping cycle.<2E>n"
else
echo "<22>nFixpoint reached, bootstrap succeeded.<2E>n"
end
# Remove old bootstrap compilers
cleanboot <EFBFBD>
delete -i -y :boot:Saved:Saved.prev:<3A> || set status 0
install <EFBFBD> $OutOfDate
flush
for i in "{BINDIR}" "{LIBDIR}" "{APPLIDIR}" "{APPLIDIR}stdlib:"
if "`exists -d "{i}"`" == ""
newfolder "{i}"
end
end
directory :byterun:
domake install
directory ::
duplicate -y :ocamlc "{BINDIR}ocamlc"
duplicate -y :ocaml "{BINDIR}ocaml"
directory :stdlib:
domake install
directory ::
duplicate -y :lex:ocamllex "{BINDIR}ocamllex"
duplicate -y :yacc:ocamlyacc "{BINDIR}ocamlyacc"
duplicate -y toplevellib.cma expunge "{LIBDIR}"
duplicate -y :typing:outcometree.cmi :typing:outcometree.mli "{LIBDIR}"
duplicate -y :toplevel:topmain.cmo "{LIBDIR}topmain.cmo"
duplicate -y :toplevel:toploop.cmi :toplevel:topdirs.cmi "{LIBDIR}"
directory :tools:
domake install
directory ::
directory :camlp4:
execute :config:config.mpw
domake install -d LIBDIR="{LIBDIR}camlp4:"
directory ::
duplicate -y :man:ocaml.help "{HELPFILE}"
for i in {OTHERLIBRARIES}
directory :otherlibs:{i}
domake install
directory :::
end
duplicate -y "{LIBDIR}"<EFBFBD> "{APPLIDIR}stdlib:"
duplicate -y :test:Moretest:graph_example.ml "{APPLIDIR}"
directory :maccaml:
domake install
directory ::
clean <EFBFBD><EFBFBD> partialclean
# The compiler
ocamlc <EFBFBD> {COMPOBJS}
{CAMLC} {LINKFLAGS} -o ocamlc {COMPOBJS}
partialclean <EFBFBD><EFBFBD>
delete -i ocamlc
# The toplevel
ocaml <EFBFBD> toplevellib.cma {TOPLEVELMAIN} expunge
{CAMLC} {LINKFLAGS} -linkall -o ocaml.tmp toplevellib.cma {TOPLEVELMAIN}
{CAMLRUN} :expunge ocaml.tmp ocaml {PERVASIVES} || set status 0
delete -i ocaml.tmp
toplevellib.cma <EFBFBD> {TOPLIB}
{CAMLC} -a -o toplevellib.cma {TOPLIB}
partialclean <EFBFBD><EFBFBD>
delete -i ocaml toplevellib.cma
# The configuration file
:utils:config.ml <20> :utils:config.mlp :config:config.Mac
delete -i :utils:config.ml
streamedit -e "/let version =/ replace /<2F><><EFBFBD>"<EFBFBD>/ <20>"/{MacVersion}<7D><><EFBFBD>"<EFBFBD>"" <20>
-e "1,$ replace /%%BYTERUN%%/ <20>"{BINDIR}ocamlrun<EFBFBD>"" <20>
-e "1,$ replace /%%LIBDIR%%/ <20>"{LIBDIR}<EFBFBD>"" <20>
-e "1,$ replace /%%EXT_OBJ%%/ '.o'" <20>
-e "1,$ replace /%%EXT_LIB%%/ '.x'" <20>
:utils:config.mlp > :utils:config.ml
partialclean <EFBFBD><EFBFBD>
delete -i :utils:config.ml
beforedepend <20><> :utils:config.ml
# The parser
:parsing:parser.mli <20> :parsing:parser.ml
echo -n
:parsing:parser.ml <20> :parsing:parser.mly
{CAMLYACC} {YACCFLAGS} :parsing:parser.mly
partialclean <EFBFBD><EFBFBD>
delete -i :parsing:parser.mli :parsing:parser.ml :parsing:parser.output
beforedepend <20><> :parsing:parser.mli :parsing:parser.ml
# The lexer
:parsing:lexer.ml <20> :parsing:lexer.mll
streamedit -e "1,$ replace /<2F><>''\223'<27><>'-<2D><>''\246'<27><>'/ '' -c <20>" <20>
-e "1,$ replace /<2F><>''\248'<27><>'-<2D><>''\255'<27><>'/ '' -c <20>" <20>
-e "1,$ replace /<2F><>''\192'<27><>'-<2D><>''\214'<27><>'/ '' -c <20>" <20>
-e "1,$ replace /<2F><>''\216'<27><>'-<2D><>''\222'<27><>'/ '' -c <20>" <20>
-e "1,$ replace /<2F><>''\216'<27><>'-<2D><>''\246'<27><>'/ '' -c <20>" <20>
<:parsing:lexer.mll >:parsing:lexer_tmp.mll
{CAMLLEX} :parsing:lexer_tmp.mll
rename -y :parsing:lexer_tmp.ml :parsing:lexer.ml
partialclean <EFBFBD><EFBFBD>
delete -i :parsing:lexer.ml
beforedepend <20><> :parsing:lexer.ml
# The auxiliary lexer for counting line numbers
:parsing:linenum.ml <20> :parsing:linenum.mll
{CAMLLEX} :parsing:linenum.mll
partialclean <EFBFBD><EFBFBD>
delete -i :parsing:linenum.ml
beforedepend <20><> :parsing:linenum.ml
# The numeric opcodes
:bytecomp:opcodes.ml <20> :byterun:instruct.h
:tools:make-opcodes.Mac :byterun:instruct.h :bytecomp:opcodes.ml
partialclean <EFBFBD><EFBFBD>
delete -i :bytecomp:opcodes.ml
beforedepend <20><> :bytecomp:opcodes.ml
# The predefined exceptions and primitives
:byterun:primitives <20>
directory :byterun:
domake primitives
directory ::
:bytecomp:runtimedef.ml <20> :byterun:primitives :byterun:fail.h
(echo 'let builtin_exceptions = [|' ; <20>
streamedit -d -e '/<2F>/<2F>* (<28>"[A-Za-z_]*<2A>")<29>0 <20>*<2A>/<2F>/ print <20>0 ";"' :byterun:fail.h | <20>
streamedit -e '$ replace /;<3B>/ "|]"'; <20>
echo 'let builtin_primitives = [|'; <20>
streamedit -e "1,$ replace /(<28>)<29>0/ ' <20>"' <20>0 '<EFBFBD>";'" -e '$ replace /;<3B>/ "|]"' :byterun:primitives; <20>
) > :bytecomp:runtimedef.ml
partialclean <EFBFBD><EFBFBD>
delete -i :bytecomp:runtimedef.ml
beforedepend <20><> :bytecomp:runtimedef.ml
# The "expunge" utility
expunge <EFBFBD> {EXPUNGEOBJS}
{CAMLC} {LINKFLAGS} -o expunge {EXPUNGEOBJS}
partialclean <EFBFBD><EFBFBD>
delete -i expunge
# The runtime system for the bytecode compiler
runtime <EFBFBD>
directory :byterun:; domake all; directory ::
clean <EFBFBD><EFBFBD>
directory :byterun:; domake clean; directory ::
alldepend <EFBFBD><EFBFBD>
directory :byterun:; domake depend; directory ::
# The library
library <EFBFBD> ocamlc
directory :stdlib; domake all; directory ::
library-cross <EFBFBD>
directory :stdlib; domake -d RUNTIME=::byterun:ocamlrun all; directory ::
partialclean <EFBFBD><EFBFBD>
directory :stdlib; domake clean; directory ::
alldepend <EFBFBD><EFBFBD>
directory :stdlib; domake depend; directory ::
# The lexer and parser generators
ocamllex <EFBFBD> ocamlyacc ocamlc
directory :lex; domake all; directory ::
partialclean <EFBFBD><EFBFBD>
directory :lex; domake clean; directory ::
alldepend <EFBFBD><EFBFBD>
directory :lex; domake depend; directory ::
ocamlyacc <EFBFBD>
directory :yacc; domake all; directory ::
clean <EFBFBD><EFBFBD>
directory :yacc; domake clean; directory ::
# Tools
ocamltools <EFBFBD> ocamlc ocamlyacc ocamllex
directory :tools; domake all; directory ::
partialclean <EFBFBD><EFBFBD>
directory :tools; domake clean; directory ::
alldepend <EFBFBD><EFBFBD>
directory :tools; domake depend; directory ::
# The extra libraries
otherlibraries <EFBFBD>
for i in {OTHERLIBRARIES}
directory :otherlibs:{i}; domake all; directory :::
end
partialclean <EFBFBD><EFBFBD>
for i in {OTHERLIBRARIES}
directory :otherlibs:{i}; domake partialclean; directory :::
end
clean <EFBFBD><EFBFBD>
for i in {OTHERLIBRARIES}
directory :otherlibs:{i}; domake clean; directory :::
end
alldepend <EFBFBD><EFBFBD>
for i in {OTHERLIBRARIES}
directory :otherlibs:{i}; domake depend; directory :::
end
# Camlp4
camlp4out <EFBFBD> ocamlc
directory :camlp4:
execute :config:config.mpw
domake all
directory ::
partialclean <EFBFBD><EFBFBD>
directory :camlp4:
execute :config:config.mpw
domake clean
directory ::
alldepend <EFBFBD><EFBFBD>
directory :camlp4:
execute :config:config.mpw
domake depend
directory ::
# The standalone application
maccaml <EFBFBD>
directory :maccaml:; domake all; directory ::
partialclean <EFBFBD><EFBFBD>
directory :maccaml:; domake partialclean; directory ::
clean <EFBFBD><EFBFBD>
directory :maccaml:; domake clean; directory ::
alldepend <EFBFBD><EFBFBD>
directory :maccaml:; domake depend; directory ::
# Clean up the test directory
clean <EFBFBD><EFBFBD>
if `exists :test:`
directory :test:; domake clean; directory ::
end
# Default rules
.cmo <EFBFBD> .ml
{CAMLC} {COMPFLAGS} -c {depdir}{default}.ml
.cmi <EFBFBD> .mli
{CAMLC} {COMPFLAGS} -c {depdir}{default}.mli
partialclean <EFBFBD><EFBFBD>
for i in utils parsing typing bytecomp driver toplevel tools
delete -i :{i}:<3A>.cm[io] || set status 0
end
depend <EFBFBD> beforedepend
for d in utils parsing typing bytecomp driver toplevel
{CAMLDEP} {DEPFLAGS} :{d}:<3A>.mli :{d}:<3A>.ml
end > Makefile.Mac.depend
alldepend <EFBFBD><EFBFBD> depend
# Make sure the config file was executed
dummy <EFBFBD> {OTHERLIBRARIES}