https://github.com/charguer/ocaml
Raw File
Tip revision: 2b9aa7ef4a1a0aedf3c3eaa4c22e324e93e0bae6 authored by Alain Frisch on 04 June 2012, 15:53:09 UTC
Fixes.
Tip revision: 2b9aa7e
Makefile.nt
#########################################################################
#                                                                       #
#                            Objective Caml                             #
#                                                                       #
#            Xavier Leroy, projet Cristal, 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

include config/Makefile
include stdlib/StdlibModules

CAMLC=boot/ocamlrun boot/ocamlc -nostdlib -I boot
CAMLOPT=boot/ocamlrun ./ocamlopt -nostdlib -I stdlib -I otherlibs/dynlink
COMPFLAGS=-strict-sequence -warn-error A $(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 asmcomp -I driver \
	 -I toplevel

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/linenum.cmo parsing/location.cmo parsing/longident.cmo \
  parsing/syntaxerr.cmo parsing/parser.cmo \
  parsing/lexer.cmo parsing/parse.cmo parsing/printast.cmo

TYPING=typing/unused_var.cmo typing/ident.cmo typing/path.cmo \
  typing/primitive.cmo typing/types.cmo \
  typing/btype.cmo typing/oprint.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/stypes.cmo typing/typecore.cmo \
  typing/typedecl.cmo typing/typeclass.cmo \
  typing/typemod.cmo

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=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

ASMCOMP=asmcomp/arch.cmo asmcomp/debuginfo.cmo \
  asmcomp/cmm.cmo asmcomp/printcmm.cmo \
  asmcomp/reg.cmo asmcomp/mach.cmo asmcomp/proc.cmo \
  asmcomp/clambda.cmo asmcomp/compilenv.cmo \
  asmcomp/closure.cmo asmcomp/cmmgen.cmo \
  asmcomp/printmach.cmo asmcomp/selectgen.cmo asmcomp/selection.cmo \
  asmcomp/comballoc.cmo asmcomp/liveness.cmo \
  asmcomp/spill.cmo asmcomp/split.cmo \
  asmcomp/interf.cmo asmcomp/coloring.cmo \
  asmcomp/reloadgen.cmo asmcomp/reload.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

TOPLEVEL=driver/pparse.cmo driver/errors.cmo driver/compile.cmo \
  driver/main_args.cmo 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)

TOPLIB=$(UTILS) $(PARSING) $(TYPING) $(COMP) $(BYTECOMP) $(TOPLEVEL)

TOPOBJS=$(TOPLEVELLIB) $(TOPLEVELSTART)

NATTOPOBJS=$(OPTUTILS) $(PARSING) $(TYPING) $(COMP) $(ASMCOMP) \
  driver/pparse.cmo driver/opterrors.cmo driver/optcompile.cmo \
  driver/main_args.cmo \
  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 \
  typing/predef.cmo bytecomp/runtimedef.cmo bytecomp/bytesections.cmo \
  bytecomp/dll.cmo \
  bytecomp/symtable.cmo toplevel/expunge.cmo

PERVASIVES=$(STDLIB_MODULES) topdirs toploop outcometree

# For users who don't read the INSTALL file
defaultentry:
	@echo "Please refer to the installation instructions in file README.win32."

# Recompile the system using the bootstrap compiler
all: runtime ocamlc ocamllex ocamlyacc ocamltools library ocaml otherlibraries ocamldoc.byte ocamlbuild.byte camlp4out $(DEBUGGER) win32gui

# 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: coldstart all

# Complete bootstrapping cycle
bootstrap:
# Save the original bootstrap compiler
	$(MAKEREC) backup
# Promote the new compiler but keep the old runtime
# This compiler runs on boot/ocamlrun and produces bytecode for byterun/ocamlrun
	$(MAKEREC) promote-cross
# Rebuild ocamlc and ocamllex (run on byterun/ocamlrun)
	$(MAKEREC) partialclean
	$(MAKEREC) ocamlc ocamllex ocamltools
# Rebuild the library (using byterun/ocamlrun ./ocamlc)
	$(MAKEREC) library-cross
# Promote the new compiler and the new runtime
	$(MAKEREC) promote
# Rebuild everything, including ocaml and the tools
	$(MAKEREC) partialclean
	$(MAKEREC) all
# Check if fixpoint reached
	$(MAKEREC) compare

LIBFILES=stdlib.cma std_exit.cmo *.cmi camlheader

# Start up the system from the distribution compiler
coldstart:
	cd byterun ; $(MAKEREC) all
	cp byterun/ocamlrun.exe boot/ocamlrun.exe
	cd yacc ; $(MAKEREC) all
	cp yacc/ocamlyacc.exe boot/ocamlyacc.exe
	cd stdlib ; $(MAKEREC) COMPILER=../boot/ocamlc all
	cd stdlib ; cp $(LIBFILES) ../boot

# Build the core system: the minimum needed to make depend and bootstrap
core : runtime ocamlc ocamllex ocamlyacc ocamltools library

# Save the current bootstrap compiler
MAXSAVED=boot/Saved/Saved.prev/Saved.prev/Saved.prev/Saved.prev/Saved.prev
backup:
	mkdir -p boot/Saved
	if test -d $(MAXSAVED); then rm -r $(MAXSAVED); fi
	mv boot/Saved boot/Saved.prev
	mkdir boot/Saved
	mv boot/Saved.prev boot/Saved/Saved.prev
	cp boot/ocamlrun.exe boot/Saved/ocamlrun.exe
	cd boot ; mv ocamlc ocamllex ocamldep ocamlyacc.exe Saved
	cd boot ; cp $(LIBFILES) Saved

# Promote the newly compiled system to the rank of cross compiler
# (Runs on the old runtime, produces code for the new runtime)
promote-cross:
	cp ocamlc boot/ocamlc
	cp lex/ocamllex boot/ocamllex
	cp yacc/ocamlyacc.exe boot/ocamlyacc.exe
	cp tools/ocamldep boot/ocamldep
	cd stdlib ; cp $(LIBFILES) ../boot

# 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
	cp byterun/ocamlrun.exe boot/ocamlrun.exe

# Restore the saved bootstrap compiler if a problem arises
restore:
	cd boot/Saved ; mv * ..
	rmdir boot/Saved
	mv boot/Saved.prev boot/Saved

# Check if fixpoint reached
compare:
	- cmp -i 4096 boot/ocamlc ocamlc
	- cmp -i 4096 boot/ocamllex lex/ocamllex
	- cmp -i 4096 boot/ocamldep tools/ocamldep

# Remove old bootstrap compilers
cleanboot:
	rm -rf boot/Saved/Saved.prev/*

# Compile the native-code compiler
opt-core: runtimeopt ocamlopt libraryopt
opt: opt-core otherlibrariesopt ocamlbuildlib.native

# Native-code versions of the tools
opt.opt: core opt-core ocamlc.opt all ocamlopt.opt ocamllex.opt \
	 ocamltoolsopt.opt ocamlbuild.native camlp4opt ocamldoc.opt

# Complete build using fast compilers
world.opt: coldstart opt.opt

# Installation
install: installbyt installopt

installbyt:
	mkdir -p $(BINDIR)
	mkdir -p $(LIBDIR)
	cd byterun ; $(MAKEREC) install
	cp ocamlc $(BINDIR)/ocamlc.exe
	cp ocaml $(BINDIR)/ocaml.exe
	cd stdlib ; $(MAKEREC) install
	cp lex/ocamllex $(BINDIR)/ocamllex.exe
	cp yacc/ocamlyacc.exe $(BINDIR)/ocamlyacc.exe
	cp toplevel/toplevellib.cma $(LIBDIR)/toplevellib.cma
	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 ; $(MAKEREC) install
	cd ocamldoc ; $(MAKEREC) install
	mkdir -p $(STUBLIBDIR)
	for i in $(OTHERLIBRARIES); do $(MAKEREC) -C otherlibs/$$i install; done
	if test -f debugger/ocamldebug.exe; then (cd debugger; $(MAKEREC) install); \
	   else :; fi
	cd win32caml ; $(MAKE) install
	./build/partial-install.sh
	cp config/Makefile $(LIBDIR)/Makefile.config
	cp README $(DISTRIB)/Readme.general.txt
	cp README.win32 $(DISTRIB)/Readme.windows.txt
	cp LICENSE $(DISTRIB)/License.txt
	cp Changes $(DISTRIB)/Changes.txt

# Installation of the native-code compiler
installopt:
	cd asmrun ; $(MAKEREC) install
	cp ocamlopt $(BINDIR)/ocamlopt.exe
	cd stdlib ; $(MAKEREC) installopt
	cd ocamldoc ; $(MAKEREC) installopt
	for i in $(OTHERLIBRARIES); do $(MAKEREC) -C otherlibs/$$i installopt; 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

clean:: partialclean

# The compiler

ocamlc: $(COMPOBJS)
	$(CAMLC) $(LINKFLAGS) -o ocamlc $(COMPOBJS)
	@sed -e 's|@compiler@|$$topdir/boot/ocamlrun $$topdir/ocamlc|' \
	  driver/ocamlcomp.sh.in > ocamlcomp.sh
	@chmod +x ocamlcomp.sh

partialclean::
	rm -f ocamlc

# The native-code compiler

ocamlopt: $(OPTOBJS)
	$(CAMLC) $(LINKFLAGS) -o ocamlopt $(OPTOBJS)
	@sed -e 's|@compiler@|$$topdir/boot/ocamlrun $$topdir/ocamlopt|' \
	  driver/ocamlcomp.sh.in > ocamlcompopt.sh
	@chmod +x ocamlcompopt.sh

partialclean::
	rm -f ocamlopt

# The toplevel

ocaml: $(TOPOBJS) expunge
	$(CAMLC) $(LINKFLAGS) -linkall -o ocaml.tmp $(TOPOBJS)
	- $(CAMLRUN) ./expunge ocaml.tmp ocaml $(PERVASIVES)
	rm -f ocaml.tmp

toplevel/toplevellib.cma: $(TOPLIB)
	$(CAMLC) -a -o $@ $(TOPLIB)

partialclean::
	rm -f ocaml

# The native toplevel

ocamlnat: ocamlopt otherlibs/dynlink/dynlink.cmxa $(NATTOPOBJS:.cmo=.cmx)
	$(CAMLOPT) $(LINKFLAGS) otherlibs/dynlink/dynlink.cmxa -o ocamlnat $(NATTOPOBJS:.cmo=.cmx) -linkall

toplevel/opttoploop.cmx: otherlibs/dynlink/dynlink.cmxa

otherlibs/dynlink/dynlink.cmxa: otherlibs/dynlink/natdynlink.ml
	cd otherlibs/dynlink && make allopt


# The configuration file

utils/config.ml: utils/config.mlp config/Makefile
	@rm -f utils/config.ml
	sed -e "s|%%LIBDIR%%|$(LIBDIR)|" \
	    -e "s|%%BYTERUN%%|ocamlrun|" \
	    -e 's|%%CCOMPTYPE%%|$(CCOMPTYPE)|' \
	    -e "s|%%BYTECC%%|$(BYTECC) $(BYTECCCOMPOPTS)|" \
	    -e "s|%%NATIVECC%%|$(NATIVECC) $(NATIVECCCOMPOPTS)|" \
	    -e "s|%%PARTIALLD%%|$(PARTIALLD)|" \
	    -e "s|%%PACKLD%%|$(PACKLD)|" \
	    -e "s|%%BYTECCLIBS%%|$(BYTECCLIBS)|" \
	    -e "s|%%NATIVECCLIBS%%|$(NATIVECCLIBS)|" \
	    -e 's|%%RANLIBCMD%%|$(RANLIBCMD)|' \
	    -e 's|%%BINUTILS_NM%%|$(BINUTILS_NM)|' \
	    -e 's|%%BINUTILS_OBJCOPY%%|$(BINUTILS_OBJCOPY)|' \
	    -e "s|%%ARCH%%|$(ARCH)|" \
	    -e "s|%%MODEL%%|$(MODEL)|" \
	    -e "s|%%SYSTEM%%|$(SYSTEM)|" \
	    -e "s|%%EXT_OBJ%%|.$(O)|" \
	    -e "s|%%EXT_ASM%%|.$(S)|" \
	    -e "s|%%EXT_LIB%%|.$(A)|" \
	    -e "s|%%EXT_DLL%%|.dll|" \
	    -e "s|%%SYSTHREAD_SUPPORT%%|true|" \
	    -e 's|%%ASM%%|$(ASM)|' \
	    -e 's|%%MKDLL%%|$(MKDLL)|' \
	    -e 's|%%MKEXE%%|$(MKEXE)|' \
	    -e 's|%%MKMAINDLL%%|$(MKMAINDLL)|' \
	    -e 's|%%CC_PROFILE%%||' \
	    utils/config.mlp > utils/config.ml
	@chmod -w utils/config.ml

partialclean::
	rm -f utils/config.ml

beforedepend:: utils/config.ml

# The parser

parsing/parser.mli parsing/parser.ml: parsing/parser.mly
	$(CAMLYACC) $(YACCFLAGS) parsing/parser.mly

partialclean::
	rm -f 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::
	rm -f 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::
	rm -f parsing/linenum.ml

beforedepend:: parsing/linenum.ml

# The bytecode compiler compiled with the native-code compiler

ocamlc.opt: $(COMPOBJS:.cmo=.cmx)
	cd asmrun ; $(MAKEREC) meta.$(O) dynlink.$(O)
	$(CAMLOPT) $(LINKFLAGS) -o ocamlc.opt $(COMPOBJS:.cmo=.cmx) asmrun/meta.$(O) asmrun/dynlink.$(O)
	@sed -e 's|@compiler@|$$topdir/ocamlc.opt|' \
	  driver/ocamlcomp.sh.in > ocamlcomp.sh
	@chmod +x ocamlcomp.sh

partialclean::
	rm -f ocamlc.opt

# The native-code compiler compiled with itself

ocamlopt.opt: $(OPTOBJS:.cmo=.cmx)
	$(CAMLOPT) $(LINKFLAGS) -o ocamlopt.opt $(OPTOBJS:.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

# The numeric opcodes

bytecomp/opcodes.ml: byterun/instruct.h
	sed -n -e "/^enum/p" -e "s|,||g" -e "/^  /p" byterun/instruct.h | \
	gawk -f tools/make-opcodes > bytecomp/opcodes.ml

partialclean::
	rm -f bytecomp/opcodes.ml

beforedepend:: bytecomp/opcodes.ml

# The predefined exceptions and primitives

byterun/primitives:
	cd byterun ; $(MAKEREC) primitives

bytecomp/runtimedef.ml: byterun/primitives byterun/fail.h
	(echo 'let builtin_exceptions = [|'; \
	 sed -n -e 's|.*/\* \("[A-Za-z_]*"\) \*/$$|  \1;|p' byterun/fail.h | \
	 sed -e '$$s/;$$//'; \
	 echo '|]'; \
	 echo 'let builtin_primitives = [|'; \
	 sed -e 's/.*/  "&";/' -e '$$s/;$$//' byterun/primitives; \
	 echo '|]') > bytecomp/runtimedef.ml

partialclean::
	rm -f bytecomp/runtimedef.ml

beforedepend:: bytecomp/runtimedef.ml

# Choose the right machine-dependent files

asmcomp/arch.ml: asmcomp/$(ARCH)/arch.ml
	cp asmcomp/$(ARCH)/arch.ml asmcomp/arch.ml

partialclean::
	rm -f asmcomp/arch.ml

beforedepend:: asmcomp/arch.ml

ifeq ($(TOOLCHAIN),msvc)
ASMCOMP_PROC=asmcomp/$(ARCH)/proc_nt.ml
ASMCOMP_EMIT=asmcomp/$(ARCH)/emit_nt.mlp
else
ASMCOMP_PROC=asmcomp/$(ARCH)/proc.ml
ASMCOMP_EMIT=asmcomp/$(ARCH)/emit.mlp
endif

asmcomp/proc.ml: $(ASMCOMP_PROC)
	cp $(ASMCOMP_PROC) asmcomp/proc.ml

partialclean::
	rm -f asmcomp/proc.ml

beforedepend:: asmcomp/proc.ml

asmcomp/selection.ml: asmcomp/$(ARCH)/selection.ml
	cp asmcomp/$(ARCH)/selection.ml asmcomp/selection.ml

partialclean::
	rm -f asmcomp/selection.ml

beforedepend:: asmcomp/selection.ml

asmcomp/reload.ml: asmcomp/$(ARCH)/reload.ml
	cp asmcomp/$(ARCH)/reload.ml asmcomp/reload.ml

partialclean::
	rm -f asmcomp/reload.ml

beforedepend:: asmcomp/reload.ml

asmcomp/scheduling.ml: asmcomp/$(ARCH)/scheduling.ml
	cp asmcomp/$(ARCH)/scheduling.ml asmcomp/scheduling.ml

partialclean::
	rm -f asmcomp/scheduling.ml

beforedepend:: asmcomp/scheduling.ml

# Preprocess the code emitters

asmcomp/emit.ml: $(ASMCOMP_EMIT) tools/cvt_emit
	boot/ocamlrun tools/cvt_emit < $(ASMCOMP_EMIT) > asmcomp/emit.ml

partialclean::
	rm -f asmcomp/emit.ml

beforedepend:: asmcomp/emit.ml

tools/cvt_emit: tools/cvt_emit.mll
	cd tools ; $(MAKEREC) cvt_emit

# The "expunge" utility

expunge: $(EXPUNGEOBJS)
	$(CAMLC) $(LINKFLAGS) -o expunge $(EXPUNGEOBJS)

partialclean::
	rm -f expunge

# The runtime system for the bytecode compiler

runtime: makeruntime stdlib/libcamlrun.$(A)

makeruntime:
	cd byterun ; $(MAKEREC) all
stdlib/libcamlrun.$(A): byterun/libcamlrun.$(A)
	cp byterun/libcamlrun.$(A) stdlib/libcamlrun.$(A)
clean::
	cd byterun ; $(MAKEREC) clean
	rm -f stdlib/libcamlrun.$(A)
alldepend::
	cd byterun ; $(MAKEREC) depend

# The runtime system for the native-code compiler

runtimeopt: makeruntimeopt stdlib/libasmrun.$(A)

makeruntimeopt:
	cd asmrun ; $(MAKEREC) all
stdlib/libasmrun.$(A): asmrun/libasmrun.$(A)
	cp asmrun/libasmrun.$(A) stdlib/libasmrun.$(A)
clean::
	cd asmrun ; $(MAKEREC) clean
	rm -f stdlib/libasmrun.$(A)
alldepend::
	cd asmrun ; $(MAKEREC) depend

# The library

library:
	cd stdlib ; $(MAKEREC) all
library-cross:
	cd stdlib ; $(MAKEREC) RUNTIME=../byterun/ocamlrun all
libraryopt:
	cd stdlib ; $(MAKEREC) allopt
partialclean::
	cd stdlib ; $(MAKEREC) clean
alldepend::
	cd stdlib ; $(MAKEREC) depend

# The lexer and parser generators

ocamllex:
	cd lex ; $(MAKEREC) all
ocamllex.opt:
	cd lex ; $(MAKEREC) allopt
partialclean::
	cd lex ; $(MAKEREC) clean
alldepend::
	cd lex ; $(MAKEREC) depend

ocamlyacc:
	cd yacc ; $(MAKEREC) all
clean::
	cd yacc ; $(MAKEREC) clean

# Tools

ocamltools: asmcomp/cmx_format.cmi
	cd tools ; $(MAKEREC) all
ocamltoolsopt.opt: asmcomp/cmx_format.cmi
	cd tools ; $(MAKEREC) opt.opt
partialclean::
	cd tools ; $(MAKEREC) clean
alldepend::
	cd tools ; $(MAKEREC) depend

# OCamldoc

ocamldoc.byte:
	cd ocamldoc ; $(MAKEREC) all
ocamldoc.opt:
	cd ocamldoc ; $(MAKEREC) opt.opt
partialclean::
	cd ocamldoc ; $(MAKEREC) clean
alldepend::
	cd ocamldoc ; $(MAKEREC) depend

# The extra libraries

otherlibraries:
	for i in $(OTHERLIBRARIES); do $(MAKEREC) -C otherlibs/$$i all; done
otherlibrariesopt:
	for i in $(OTHERLIBRARIES); do $(MAKEREC) -C otherlibs/$$i allopt; done
partialclean::
	for i in $(OTHERLIBRARIES); do $(MAKEREC) -C otherlibs/$$i partialclean; done
clean::
	for i in $(OTHERLIBRARIES); do $(MAKEREC) -C otherlibs/$$i clean; done
alldepend::
	for i in $(OTHERLIBRARIES); do $(MAKEREC) -C otherlibs/$$i depend; done

# The replay debugger

ocamldebugger: ocamlc ocamlyacc ocamllex
	cd debugger; $(MAKEREC) all
partialclean::
	cd debugger; $(MAKEREC) clean
alldepend::
	cd debugger; $(MAKEREC) depend

# Camlp4

camlp4out: ocamlc otherlibraries ocamlbuild-mixed-boot ocamlbuild.byte
	./build/camlp4-byte-only.sh
camlp4opt: ocamlopt otherlibrariesopt ocamlbuild-mixed-boot ocamlbuild.native
	./build/camlp4-native-only.sh

# Ocamlbuild

ocamlbuild.byte: ocamlc otherlibraries ocamlbuild-mixed-boot
	./build/ocamlbuild-byte-only.sh
ocamlbuild.native: ocamlopt otherlibrariesopt ocamlbuild-mixed-boot
	./build/ocamlbuild-native-only.sh
ocamlbuildlib.native: ocamlopt otherlibrariesopt ocamlbuild-mixed-boot
	./build/ocamlbuildlib-native-only.sh


.PHONY: ocamlbuild-mixed-boot
ocamlbuild-mixed-boot:
	./build/mixed-boot.sh
partialclean::
	rm -rf _build

# The Win32 toplevel GUI

win32gui:
	cd win32caml ; $(MAKE) all

clean::
	cd win32caml ; $(MAKE) clean

# Default rules

.SUFFIXES: .ml .mli .cmo .cmi .cmx

.ml.cmo:
	$(CAMLC) $(COMPFLAGS) -c $<

.mli.cmi:
	$(CAMLC) $(COMPFLAGS) -c $<

.ml.cmx:
	$(CAMLOPT) $(COMPFLAGS) -c $<

partialclean::
	rm -f utils/*.cm* utils/*.$(O) utils/*.$(S)
	rm -f parsing/*.cm* parsing/*.$(O) parsing/*.$(S)
	rm -f typing/*.cm* typing/*.$(O) typing/*.$(S)
	rm -f bytecomp/*.cm* bytecomp/*.$(O) bytecomp/*.$(S)
	rm -f asmcomp/*.cm* asmcomp/*.$(O) asmcomp/*.$(S)
	rm -f driver/*.cm* driver/*.$(O) driver/*.$(S)
	rm -f toplevel/*.cm* toplevel/*.$(O) toplevel/*.$(S)
	rm -f tools/*.cm* tools/*.$(O) tools/*.$(S)

depend: beforedepend
	(for d in utils parsing typing bytecomp asmcomp driver toplevel; \
	 do $(CAMLDEP) $(DEPFLAGS) $$d/*.mli $$d/*.ml; \
	 done) > .depend

alldepend:: depend

include .depend
back to top