https://github.com/charguer/ocaml
Raw File
Tip revision: fc5e0b7e9049008f2999aaa21fb455b5552b180c authored by Jacques Garrigue on 30 November 1999, 14:22:33 UTC
converter
Tip revision: fc5e0b7
Makefile.Mac
# The main Makefile

MacVersion = "Mac{MAJOR}.{MINOR}{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: Č
           -I :driver: -I :toplevel:

UTILS = :utils:misc.cmo :utils:formatmsg.cmo :utils:tbl.cmo :utils:config.cmo Č
        :utils:clflags.cmo :utils:terminfo.cmo :utils:ccomp.cmo Č
        :utils:warnings.cmo

PARSING = :parsing:linenum.cmo :parsing:location.cmo :parsing:longident.cmo Č
          :parsing:syntaxerr.cmo :parsing:pstream.cmo :parsing:parser.cmo Č
          :parsing:lexer.cmo :parsing:parse.cmo

TYPING = :typing:ident.cmo :typing:path.cmo Č
  :typing:primitive.cmo :typing:types.cmo Č
  :typing:btype.cmo Č
  :typing:subst.cmo :typing:predef.cmo Č
  :typing:datarepr.cmo :typing:env.cmo Č
  :typing:typedtree.cmo Č
  :typing:ctype.cmo :typing:printtyp.cmo Č
  :typing:includeclass.cmo Č
  :typing:mtype.cmo :typing:includecore.cmo Č
  :typing:includemod.cmo :typing:parmatch.cmo Č
  :typing:typetexp.cmo :typing:typecore.cmo Č
  :typing:typedecl.cmo :typing:typeclass.cmo Č
  :typing:typemod.cmo

COMP = :bytecomp:lambda.cmo :bytecomp:printlambda.cmo Č
  :bytecomp:typeopt.cmo :bytecomp:matching.cmo Č
  :bytecomp:translobj.cmo :bytecomp:translcore.cmo Č
  :bytecomp:translclass.cmo :bytecomp:translmod.cmo Č
  :bytecomp:simplif.cmo :bytecomp:runtimedef.cmo

BYTECOMP = :bytecomp:meta.cmo :bytecomp:instruct.cmo :bytecomp:bytegen.cmo Č
  :bytecomp:printinstr.cmo :bytecomp:opcodes.cmo :bytecomp:emitcode.cmo Č
  :bytecomp:symtable.cmo :bytecomp:bytelibrarian.cmo :bytecomp:bytelink.cmo

DRIVER = :driver:errors.cmo :driver:compile.cmo :driver:main_args.cmo Č
         :driver:main.cmo

TOPLEVEL = :driver:errors.cmo :driver:compile.cmo Č
  :toplevel:genprintval.cmo Č
  :toplevel:printval.cmo :toplevel:toploop.cmo Č
  :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:formatmsg.cmo :utils:tbl.cmo Č
  :utils:config.cmo :utils:clflags.cmo Č
  :typing:ident.cmo :typing:path.cmo Č
  :typing:types.cmo :typing:btype.cmo :typing:predef.cmo Č
  :bytecomp:runtimedef.cmo :bytecomp:symtable.cmo Č
  :toplevel:expunge.cmo

PERVASIVES = arg array buffer callback char digest filename format gc hashtbl Č
  lexing list map obj parsing pervasives printexc printf queue random Č
  set sort stack string stream sys oo genlex topdirs toploop weak lazy Č
  marshal

# Recompile the system using the bootstrap compiler
all ─ runtime ocamlc ocamllex ocamlyacc ocamltools library ocaml Č
      otherlibraries 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 ─
    domake coldstart
    domake all

# Complete bootstrapping cycle
bootstrap ─
      # 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 :┼.cmi camlheader

# Start up the system from the distribution compiler
coldstart ─
    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 ::

# Save the current bootstrap compiler
backup ─
    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 ─
    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 ─ promote-cross
    duplicate -y :byterun:ocamlrun :boot:ocamlrun

clean ──
    delete -i :boot:┼.cm[aio] || set status 0
    delete -i :boot:camlheader :boot:ocamlrun :boot:ocamlyacc

# Restore the saved bootstrap compiler if a problem arises
restore ─
    move -y :boot:Saved:┼ :boot:
    delete -y :boot:Saved:
    move -y :boot:Saved.prev: :boot:Saved:

# Check if fixpoint reached
compare ─
    set exit 0
    equal -q :boot:ocamlc :ocamlc && equal -q :boot:ocamllex :lex:ocamllex
    if {status}
      echo "ČnFixpoint not reached, try one more bootstrapping cycle.Čn"
    else
      echo "ČnFixpoint reached, bootstrap succeeded.Čn"
    end

# Remove old bootstrap compilers
cleanboot ─
    delete -i -y :boot:Saved:Saved.prev:┼ || set status 0


install ─ $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 :toplevel:topmain.cmo "{LIBDIR}topmain.cmo"
    duplicate -y :toplevel:toploop.cmi :toplevel:topdirs.cmi "{LIBDIR}"
    directory :tools:
    domake install
    directory ::
    duplicate -y :man:ocaml.help "{HELPFILE}"
    for i in {OTHERLIBRARIES}
      directory :otherlibs:{i}
      domake install
      directory :::
    end
    duplicate -y "{LIBDIR}"┼ "{APPLIDIR}stdlib:"
    directory :maccaml:
    domake install
    directory ::

clean ── partialclean


# The compiler

ocamlc ─ {COMPOBJS}
    {CAMLC} {LINKFLAGS} -o ocamlc {COMPOBJS}

partialclean ──
    delete -i ocamlc


# The toplevel

ocaml ─ 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 ─ {TOPLIB}
    {CAMLC} -a -o toplevellib.cma {TOPLIB}

partialclean ──
    delete -i ocaml toplevellib.cma


# The configuration file

:utils:config.ml ─ :utils:config.mlp :config:config.Mac
    delete -i :utils:config.ml
    streamedit -e "/let version =/ replace /ČČČ"░/ Č"/{MacVersion}ČČČ"Č"" Č
               -e "1,$ replace /%%BYTERUN%%/ Č"{BINDIR}ocamlrunČ"" Č
               -e "1,$ replace /%%LIBDIR%%/ Č"{LIBDIR}Č"" Č
               -e "1,$ replace /%%EXT_OBJ%%/ '.o'" Č
               -e "1,$ replace /%%EXT_LIB%%/ '.x'" Č
               :utils:config.mlp > :utils:config.ml

partialclean ──
    delete -i :utils:config.ml

beforedepend ── :utils:config.ml


# The parser

:parsing:parser.mli ─ :parsing:parser.ml
    echo -n

:parsing:parser.ml ─ :parsing:parser.mly
    {CAMLYACC} {YACCFLAGS} :parsing:parser.mly

partialclean ──
    delete -i :parsing:parser.mli :parsing:parser.ml :parsing:parser.output

beforedepend ── :parsing:parser.mli :parsing:parser.ml


# The lexer

:parsing:lexer.ml ─ :parsing:lexer.mll
    {CAMLLEX} :parsing:lexer.mll

partialclean ──
    delete -i :parsing:lexer.ml

beforedepend ── :parsing:lexer.ml


# The auxiliary lexer for counting line numbers

:parsing:linenum.ml ─ :parsing:linenum.mll
    {CAMLLEX} :parsing:linenum.mll

partialclean ──
    delete -i :parsing:linenum.ml

beforedepend ── :parsing:linenum.ml


# The numeric opcodes

:bytecomp:opcodes.ml ─ :byterun:instruct.h
    :tools:make-opcodes.Mac :byterun:instruct.h :bytecomp:opcodes.ml

partialclean ──
    delete -i :bytecomp:opcodes.ml

beforedepend ── :bytecomp:opcodes.ml


# The predefined exceptions and primitives

:byterun:primitives ─
    directory :byterun:
    domake primitives
    directory ::

:bytecomp:runtimedef.ml ─ :byterun:primitives :byterun:fail.h
    (echo 'let builtin_exceptions = [|' ; Č
     streamedit -d -e '/Č/Č* (Č"[A-Za-z_]*Č")©0 Č*Č/░/ print ©0 ";"' :byterun:fail.h | Č
     streamedit -e '$ replace /;░/ "|]"'; Č
     echo 'let builtin_primitives = [|'; Č
     streamedit -e "1,$ replace /(┼)©0/ '  Č"' ©0 'Č";'" -e '$ replace /;░/ "|]"' :byterun:primitives; Č
    ) > :bytecomp:runtimedef.ml

partialclean ──
    delete -i :bytecomp:runtimedef.ml

beforedepend ── :bytecomp:runtimedef.ml


# The "expunge" utility

expunge ─ {EXPUNGEOBJS}
    {CAMLC} {LINKFLAGS} -o expunge {EXPUNGEOBJS}

partialclean ──
    delete -i expunge


# The runtime system for the bytecode compiler

runtime ─
    directory :byterun:; domake all; directory ::
clean ──
    directory :byterun:; domake clean; directory ::
alldepend ──
    directory :byterun:; domake depend; directory ::


# The library

library ─ ocamlc
    directory :stdlib; domake all; directory ::
library-cross ─
    directory :stdlib; domake -d RUNTIME=::byterun:ocamlrun all; directory ::
partialclean ──
    directory :stdlib; domake clean; directory ::
alldepend ──
    directory :stdlib; domake depend; directory ::


# The lexer and parser generators

ocamllex ─ ocamlyacc ocamlc
    directory :lex; domake all; directory ::
partialclean ──
    directory :lex; domake clean; directory ::
alldepend ──
    directory :lex; domake depend; directory ::

ocamlyacc ─
    directory :yacc; domake all; directory ::
clean ──
    directory :yacc; domake clean; directory ::


# Tools

ocamltools ─ ocamlc ocamlyacc ocamllex
    directory :tools; domake all; directory ::
partialclean ──
    directory :tools; domake clean; directory ::
alldepend ──
    directory :tools; domake depend; directory ::


# The extra libraries

otherlibraries ─
    for i in {OTHERLIBRARIES}
      directory :otherlibs:{i}; domake all; directory :::
    end
partialclean ──
    for i in {OTHERLIBRARIES}
      directory :otherlibs:{i}; domake partialclean; directory :::
    end
clean ──
    for i in {OTHERLIBRARIES}
      directory :otherlibs:{i}; domake clean; directory :::
    end
alldepend ──
    for i in {OTHERLIBRARIES}
      directory :otherlibs:{i}; domake depend; directory :::
    end


# The standalone application

maccaml ─
    directory :maccaml:; domake all; directory ::
partialclean ──
    directory :maccaml:; domake partialclean; directory ::
clean ──
    directory :maccaml:; domake clean; directory ::
alldepend ──
    directory :maccaml:; domake depend; directory ::


# Clean up the test directory

clean ──
    if `exists :test:`
      directory :test:; domake clean; directory ::
    end


# Default rules

.cmo ─ .ml
    {CAMLC} {COMPFLAGS} -c {depdir}{default}.ml

.cmi ─ .mli
    {CAMLC} {COMPFLAGS} -c {depdir}{default}.mli

partialclean ──
    for i in utils parsing typing bytecomp driver toplevel tools
      delete -i :{i}:┼.cm[io] || set status 0
    end

depend ─ beforedepend
    for d in utils parsing typing bytecomp driver toplevel
      {CAMLDEP} {DEPFLAGS} :{d}:┼.mli :{d}:┼.ml
    end > Makefile.Mac.depend

alldepend ── depend


# Make sure the config file was executed
dummy ─ {OTHERLIBRARIES}
back to top