CAMLC = ::boot:ocamlrun ::ocamlc -I ::stdlib: -I :KB: -I :Lex:
CAMLYACC = ::yacc:ocamlyacc
CAMLLEX = ::boot:ocamlrun ::lex:ocamllex
CAMLDEP = ::boot:ocamlrun ::tools:ocamldep
CAMLRUN = ::byterun:ocamlrun

BYTE_EXE = fib.byt takc.byt taku.byt sieve.byt quicksort.byt quicksort.fast.byt ¶
  fft.byt fft.fast.byt soli.byt soli.fast.byt boyer.byt kb.byt ¶
  nucleic.byt genlex.byt bdd.byt

all Ä test

# KB

BYTE_KB = :KB:terms.cmo :KB:equations.cmo :KB:kb.cmo :KB:orderings.cmo ¶
          :KB:kbmain.cmo

kb.byt Ä {BYTE_KB}
        {CAMLC} {BYTE_KB} -o kb.byt

clean ÄÄ
        delete -i :KB:Å.cm[io] || set status 0

# Genlex

BYTE_GENLEX = :Lex:syntax.cmo :Lex:scan_aux.cmo :Lex:scanner.cmo ¶
  :Lex:gram_aux.cmo :Lex:grammar.cmo :Lex:lexgen.cmo :Lex:output.cmo :Lex:main.cmo

genlex.byt Ä {BYTE_GENLEX}
        {CAMLC} {BYTE_GENLEX} -o genlex.byt

clean ÄÄ
        delete -i :Lex:Å.cm[io] || set status 0

:Lex:grammar.mli Ä :Lex:grammar.ml
        echo -n

:Lex:grammar.ml Ä :Lex:grammar.mly ::yacc:ocamlyacc
        {CAMLYACC} {YACCFLAGS} :Lex:grammar.mly

clean ÄÄ
        delete -i :Lex:grammar.ml :Lex:grammar.mli

beforedepend ÄÄ :Lex:grammar.ml :Lex:grammar.mli

:Lex:scanner.ml Ä :Lex:scanner.mll ::lex:ocamllex
        {CAMLLEX} :Lex:scanner.mll

clean ÄÄ
        delete -i :Lex:scanner.ml

beforedepend ÄÄ :Lex:scanner.ml

# Common rules

.byt Ä .ml
        {CAMLC} -o {targdir}{default}.byt {depdir}{default}.ml

.fast.byt Ä .ml
        {CAMLC} -unsafe -o {targdir}{default}.fast.byt {depdir}{default}.ml

.cmi Ä .mli
        {CAMLC} -c {depdir}{default}.mli

.cmo Ä .ml
        {CAMLC} -c {depdir}{default}.ml

{BYTE_EXE} {BYTE_KB} {BYTE_GENLEX} Ä ::ocamlc
{BYTE_EXE} Ä ::stdlib:stdlib.cma

clean ÄÄ
  delete -i Å.byt || set status 0
  delete -i Å.cm[io] || set status 0
  directory :Moretest; domake clean; directory ::

# Regression test

test Ä {BYTE_EXE}
        for prog in `echo {BYTE_EXE} | streamedit -e '1 replace /.byt/ "" -c °'`
          echo {prog}
          if "`exists :Results:{prog}.runtest.Mac`"
            :Results:{prog}.runtest.Mac test {CAMLRUN} {prog}.byt
          else
            {CAMLRUN} {prog}.byt > "{tempfolder}ocaml-test"
            equal -d "{tempfolder}ocaml-test" :Results:{prog}.out
          end
        end

clean ÄÄ
        delete -i :Lex:testscanner.ml "{tempfolder}ocaml-test"

# Benchmark

bench Ä {BYTE_EXE}
        for prog in `echo {BYTE_EXE} | streamedit -e '1 replace /.byt/ "" -c °'`
          echo {prog}
          if "`exists :Results:{prog}.runtest.Mac`"
            :Results:{prog}.runtest.Mac bench {CAMLRUN} {prog}.byt
          else
            time "{CAMLRUN} {prog}.byt ·dev:null"
          end
        end

# Dependencies

depend Ä beforedepend
        {CAMLDEP} -I :KB: -I :Lex: Å.ml :KB:Å.mli :KB:Å.ml :Lex:Å.mli ¶
                  :Lex:Å.ml > Makefile.Mac.depend
