ocaml/tools/Makefile.shared

349 lines
9.1 KiB
Makefile
Raw Normal View History

#########################################################################
# #
# OCaml #
# #
# 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. #
# #
#########################################################################
include ../config/Makefile
CAMLRUN=../boot/ocamlrun
CAMLC=$(CAMLRUN) ../boot/ocamlc -strict-sequence -nostdlib -I ../boot
CAMLOPT=$(CAMLRUN) ../ocamlopt -nostdlib -I ../stdlib
CAMLLEX=$(CAMLRUN) ../boot/ocamllex
INCLUDES=-I ../utils -I ../parsing -I ../typing -I ../bytecomp -I ../asmcomp \
-I ../driver -I ../toplevel
COMPFLAGS= -w +32+33+34+35+36+37+38+39 -warn-error A $(INCLUDES)
LINKFLAGS=$(INCLUDES)
all: ocamldep ocamlprof ocamlcp ocamloptp ocamlmktop ocamlmklib dumpobj \
objinfo read_cmt
moretools: ocamlast
all: tast_iter.cmo
# scrapelabels addlabels
.PHONY: all moretools
opt.opt: ocamldep.opt read_cmt.opt
.PHONY: opt.opt
# The dependency generator
CAMLDEP_OBJ=depend.cmo ocamldep.cmo
CAMLDEP_IMPORTS=misc.cmo config.cmo clflags.cmo terminfo.cmo \
warnings.cmo location.cmo longident.cmo \
syntaxerr.cmo ast_helper.cmo parser.cmo lexer.cmo parse.cmo \
ccomp.cmo pparse.cmo
ocamldep: depend.cmi $(CAMLDEP_OBJ)
$(CAMLC) $(LINKFLAGS) -o ocamldep $(CAMLDEP_IMPORTS) $(CAMLDEP_OBJ)
ocamldep.opt: depend.cmi $(CAMLDEP_OBJ:.cmo=.cmx)
$(CAMLOPT) $(LINKFLAGS) -o ocamldep.opt $(CAMLDEP_IMPORTS:.cmo=.cmx) \
$(CAMLDEP_OBJ:.cmo=.cmx)
# ocamldep is precious: sometimes we are stuck in the middle of a
# bootstrap and we need to remake the dependencies
clean::
if test -f ocamldep; then mv -f ocamldep ocamldep.bak; else :; fi
rm -f ocamldep.opt
install::
cp ocamldep $(BINDIR)/ocamldep$(EXE)
if test -f ocamldep.opt; \
then cp ocamldep.opt $(BINDIR)/ocamldep.opt$(EXE); else :; fi
# The profiler
CSLPROF=ocamlprof.cmo
CSLPROF_IMPORTS=misc.cmo config.cmo clflags.cmo terminfo.cmo \
warnings.cmo location.cmo longident.cmo \
syntaxerr.cmo ast_helper.cmo parser.cmo lexer.cmo parse.cmo
ocamlprof: $(CSLPROF) profiling.cmo
$(CAMLC) $(LINKFLAGS) -o ocamlprof $(CSLPROF_IMPORTS) $(CSLPROF)
ocamlcp: ocamlcp.cmo
$(CAMLC) $(LINKFLAGS) -o ocamlcp warnings.cmo main_args.cmo ocamlcp.cmo
ocamloptp: ocamloptp.cmo
$(CAMLC) $(LINKFLAGS) -o ocamloptp warnings.cmo main_args.cmo \
ocamloptp.cmo
opt:: profiling.cmx
install::
cp ocamlprof $(BINDIR)/ocamlprof$(EXE)
cp ocamlcp $(BINDIR)/ocamlcp$(EXE)
cp ocamloptp $(BINDIR)/ocamloptp$(EXE)
cp profiling.cmi profiling.cmo $(LIBDIR)
installopt::
cp profiling.cmx profiling.o $(LIBDIR)
clean::
rm -f ocamlprof ocamlcp ocamloptp
# To help building mixed-mode libraries (OCaml + C)
ocamlmklib: myocamlbuild_config.cmo ocamlmklib.cmo
$(CAMLC) $(LINKFLAGS) -o ocamlmklib myocamlbuild_config.cmo \
ocamlmklib.cmo
ocamlmklib.cmo: myocamlbuild_config.cmi
myocamlbuild_config.cmi: myocamlbuild_config.cmo
myocamlbuild_config.ml: ../config/Makefile ../build/mkmyocamlbuild_config.sh
../build/mkmyocamlbuild_config.sh
cp ../myocamlbuild_config.ml .
install::
cp ocamlmklib $(BINDIR)/ocamlmklib$(EXE)
clean::
rm -f ocamlmklib
ocamlmklib.ml: ocamlmklib.mlp ../config/Makefile
echo '(* THIS FILE IS GENERATED FROM ocamlmklib.mlp *)' >ocamlmklib.ml
sed -e "s|%%BINDIR%%|$(BINDIR)|" \
-e "s|%%SUPPORTS_SHARED_LIBRARIES%%|$(SUPPORTS_SHARED_LIBRARIES)|" \
-e "s|%%MKSHAREDLIB%%|$(MKSHAREDLIB)|" \
-e "s|%%BYTECCRPATH%%|$(BYTECCRPATH)|" \
-e "s|%%NATIVECCRPATH%%|$(NATIVECCRPATH)|" \
-e "s|%%MKSHAREDLIBRPATH%%|$(MKSHAREDLIBRPATH)|" \
-e "s|%%RANLIB%%|$(RANLIB)|" \
ocamlmklib.mlp >> ocamlmklib.ml
beforedepend:: ocamlmklib.ml
clean::
rm -f ocamlmklib.ml
# Converter olabl/ocaml 2.99 to ocaml 3
OCAML299TO3= lexer299.cmo ocaml299to3.cmo
LIBRARY3= misc.cmo warnings.cmo location.cmo
ocaml299to3: $(OCAML299TO3)
$(CAMLC) $(LINKFLAGS) -o ocaml299to3 $(LIBRARY3) $(OCAML299TO3)
lexer299.ml: lexer299.mll
$(CAMLLEX) lexer299.mll
#install::
# cp ocaml299to3 $(BINDIR)/ocaml299to3$(EXE)
clean::
rm -f ocaml299to3 lexer299.ml
# Label remover for interface files (upgrade 3.02 to 3.03)
SCRAPELABELS= lexer301.cmo scrapelabels.cmo
scrapelabels: $(SCRAPELABELS)
$(CAMLC) $(LINKFLAGS) -o scrapelabels $(LIBRARY3) $(SCRAPELABELS)
lexer301.ml: lexer301.mll
$(CAMLLEX) lexer301.mll
#install::
# cp scrapelabels $(LIBDIR)
clean::
rm -f scrapelabels lexer301.ml
# Insert labels following an interface file (upgrade 3.02 to 3.03)
ADDLABELS_IMPORTS=misc.cmo config.cmo clflags.cmo terminfo.cmo \
warnings.cmo location.cmo longident.cmo \
syntaxerr.cmo ast_helper.cmo parser.cmo lexer.cmo parse.cmo
addlabels: addlabels.cmo
$(CAMLC) $(LINKFLAGS) -w sl -o addlabels \
$(ADDLABELS_IMPORTS) addlabels.cmo
#install::
# cp addlabels $(LIBDIR)
clean::
rm -f addlabels
# The preprocessor for asm generators
CVT_EMIT=cvt_emit.cmo
cvt_emit: $(CVT_EMIT)
$(CAMLC) $(LINKFLAGS) -o cvt_emit $(CVT_EMIT)
# cvt_emit is precious: sometimes we are stuck in the middle of a
# bootstrap and we need to remake the dependencies
clean::
if test -f cvt_emit; then mv -f cvt_emit cvt_emit.bak; else :; fi
cvt_emit.ml: cvt_emit.mll
$(CAMLLEX) cvt_emit.mll
clean::
rm -f cvt_emit.ml
beforedepend:: cvt_emit.ml
# Reading cmt files
READ_CMT= \
../utils/misc.cmo \
../utils/warnings.cmo \
../utils/tbl.cmo \
../utils/consistbl.cmo \
../utils/config.cmo \
../utils/clflags.cmo \
../parsing/location.cmo \
../parsing/longident.cmo \
../parsing/lexer.cmo \
../parsing/pprintast.cmo \
../parsing/ast_helper.cmo \
../typing/ident.cmo \
../typing/path.cmo \
../typing/types.cmo \
../typing/typedtree.cmo \
../typing/btype.cmo \
../typing/subst.cmo \
../typing/predef.cmo \
../typing/datarepr.cmo \
../typing/cmi_format.cmo \
../typing/env.cmo \
../typing/ctype.cmo \
../typing/oprint.cmo \
../typing/primitive.cmo \
../typing/printtyp.cmo \
../typing/mtype.cmo \
../typing/envaux.cmo \
../typing/typedtreeMap.cmo \
../typing/typedtreeIter.cmo \
../typing/cmt_format.cmo \
../typing/stypes.cmo \
\
untypeast.cmo \
tast_iter.cmo \
cmt2annot.cmo read_cmt.cmo
read_cmt: $(READ_CMT)
$(CAMLC) $(LINKFLAGS) -o read_cmt $(READ_CMT)
read_cmt.opt: $(READ_CMT:.cmo=.cmx)
$(CAMLOPT) $(LINKFLAGS) -o read_cmt.opt $(READ_CMT:.cmo=.cmx)
clean::
rm -f read_cmt read_cmt.opt
beforedepend::
# The bytecode disassembler
DUMPOBJ=opnames.cmo dumpobj.cmo
dumpobj: $(DUMPOBJ)
$(CAMLC) $(LINKFLAGS) -o dumpobj \
misc.cmo tbl.cmo config.cmo ident.cmo \
opcodes.cmo bytesections.cmo $(DUMPOBJ)
clean::
rm -f dumpobj
opnames.ml: ../byterun/instruct.h
unset LC_ALL || : ; \
unset LC_CTYPE || : ; \
unset LC_COLLATE LANG || : ; \
sed -e '/\/\*/d' \
-e '/^#/d' \
-e 's/enum \(.*\) {/let names_of_\1 = [|/' \
-e 's/};$$/ |]/' \
-e 's/\([A-Z][A-Z_0-9a-z]*\)/"\1"/g' \
-e 's/,/;/g' \
../byterun/instruct.h > opnames.ml
clean::
rm -f opnames.ml
beforedepend:: opnames.ml
# Display info on compiled files
objinfo_helper$(EXE): objinfo_helper.c ../config/s.h
$(BYTECC) -o objinfo_helper$(EXE) $(BYTECCCOMPOPTS) \
objinfo_helper.c $(LIBBFD_LINK)
OBJINFO=../utils/misc.cmo ../utils/config.cmo \
../utils/warnings.cmo ../parsing/location.cmo \
../typing/cmi_format.cmo ../bytecomp/bytesections.cmo \
objinfo.cmo
objinfo: objinfo_helper$(EXE) $(OBJINFO)
$(CAMLC) -o objinfo $(OBJINFO)
install::
cp objinfo $(BINDIR)/ocamlobjinfo$(EXE)
cp objinfo_helper$(EXE) $(LIBDIR)/objinfo_helper$(EXE)
clean::
rm -f objinfo objinfo_helper$(EXE)
# Scan object files for required primitives
PRIMREQ=primreq.cmo
primreq: $(PRIMREQ)
$(CAMLC) $(LINKFLAGS) -o primreq config.cmo $(PRIMREQ)
clean::
rm -f primreq
# Dump the Parsetree representation of OCaml code, in OCaml syntax
OCAMLAST=dump_ast.cmo
ocamlast: $(OCAMLAST)
$(CAMLC) $(LINKFLAGS) -o ocamlast ../compilerlibs/ocamlcommon.cma ../compilerlibs/ocamlbytecomp.cma ../compilerlibs/ocamltoplevel.cma $(OCAMLAST)
clean::
rm -rf ocamlast
install::
cp ocamlast $(BINDIR)/ocamlast$(EXE)
# Common stuff
.SUFFIXES:
.SUFFIXES: .ml .cmo .mli .cmi .cmx
.ml.cmo:
$(CAMLC) -c $(COMPFLAGS) $<
.mli.cmi:
$(CAMLC) -c $(COMPFLAGS) $<
.ml.cmx:
$(CAMLOPT) $(COMPFLAGS) -c $<
clean::
rm -f *.cmo *.cmi *.cma *.dll *.so *.lib *.a
depend: beforedepend
$(CAMLRUN) ./ocamldep $(INCLUDES) *.mli *.ml > .depend
.PHONY: clean install beforedepend depend
include .depend