118 lines
3.2 KiB
Makefile
118 lines
3.2 KiB
Makefile
# -*- Makefile -*-
|
|
##############################################################################
|
|
# Generic variables
|
|
##############################################################################
|
|
|
|
OBJS = $(SRC:.ml=.cmo)
|
|
OPTOBJS = $(SRC:.ml=.cmx)
|
|
|
|
INCLUDES=$(INCLUDEDIRS:%=-I %) $(INCLUDESEXTRA)
|
|
|
|
LIB=$(LIBNAME).cma
|
|
OPTLIB=$(LIB:.cma=.cmxa)
|
|
|
|
##############################################################################
|
|
# Generic OCaml variables
|
|
##############################################################################
|
|
|
|
# This flag can also be used in subdirectories so don't change its name here.
|
|
# For profiling use: -p -inline 0
|
|
OPTFLAGS=-thread
|
|
|
|
# The OPTBIN variable is here to allow to use ocamlc.opt instead of
|
|
# ocaml, when it is available, which speeds up compilation. So
|
|
# if you want the fast version of the ocaml chain tools, set this var
|
|
# or setenv it to ".opt" in your startup script.
|
|
OPTBIN ?= #.opt
|
|
|
|
# coupling: ../Makefile.common, but want independent commons/
|
|
OCAMLCFLAGS ?= -g -dtypes $(OCAMLCFLAGS_EXTRA) -thread -w +9
|
|
|
|
# The OCaml tools.
|
|
OCAMLC =ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES)
|
|
OCAMLOPT=ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES)
|
|
OCAMLLEX = ocamllex$(OPTBIN)
|
|
OCAMLYACC= ocamlyacc -v
|
|
OCAMLDEP = ocamldep$(OPTBIN) $(INCLUDES)
|
|
OCAMLMKTOP=ocamlmktop -g -custom $(INCLUDES)
|
|
|
|
OCAMLMKLIB ?= ocamlmklib
|
|
CC=gcc
|
|
|
|
##############################################################################
|
|
# Top rules
|
|
##############################################################################
|
|
|
|
|
|
all:: $(LIB)
|
|
all.opt: $(OPTLIB)
|
|
opt: all.opt
|
|
top: $(LIBNAME).top
|
|
|
|
$(LIB): $(OBJS) $(COBJS)
|
|
$(OCAMLMKLIB) -o $(LIBNAME).cma $(BUILTINLIBS) $^
|
|
|
|
$(OPTLIB): $(OPTOBJS) $(COBJS)
|
|
$(OCAMLMKLIBOPT) -o $(LIBNAME).cmxa $(BUILTINLIBSOPT) $^
|
|
|
|
$(LIBNAME).top: $(OBJS)
|
|
$(OCAMLMKTOP) -o $@ $(SYSLIBS) $^
|
|
|
|
clean::
|
|
rm -f $(LIBNAME).top
|
|
|
|
##############################################################################
|
|
# Generic rules
|
|
##############################################################################
|
|
|
|
.SUFFIXES:
|
|
.SUFFIXES: .ml .mli .cmo .cmi .cmx
|
|
|
|
.ml.cmo:
|
|
$(OCAMLC) -c $<
|
|
.mli.cmi:
|
|
$(OCAMLC) -c $<
|
|
.ml.cmx:
|
|
$(OCAMLOPT) -c $<
|
|
|
|
clean::
|
|
rm -f *.cm[iox] *.o *.a *.cma *.cmxa *.annot *.cmt *.cmti *.so
|
|
rm -f *~ .*~ #*#
|
|
|
|
clean::
|
|
for i in $(SUBDIRS); do (cd $$i; \
|
|
rm -f *.cm[iox] *.cmt* *.o *.a *.cma *.cmxa *.annot *~ .*~ ; \
|
|
cd ..; ) \
|
|
done
|
|
|
|
depend:
|
|
$(OCAMLDEP) *.mli *.ml > .depend
|
|
for i in $(SUBDIRS); do $(OCAMLDEP) $$i/*.ml $$i/*.mli >> .depend; done
|
|
|
|
distclean::
|
|
rm -f .depend
|
|
|
|
-include .depend
|
|
|
|
##############################################################################
|
|
# install
|
|
##############################################################################
|
|
|
|
OCAMLSTDLIB=`ocamlc -where`
|
|
install: all all.opt
|
|
mkdir -p $(OCAMLSTDLIB)/$(LIBNAME)
|
|
cp $(LIBNAME).cma $(LIBNAME).cmxa \
|
|
common.mli ocaml.mli \
|
|
$(OCAMLSTDLIB)/$(LIBNAME)
|
|
|
|
install-findlib: all all.opt
|
|
ocamlfind install $(LIBNAME) META \
|
|
$(LIBNAME).cma $(LIBNAME).cmxa $(LIBNAME).a *.cmi $(EXPORTSRC)
|
|
|
|
uninstall-findlib:
|
|
ocamlfind remove $(LIBNAME)
|
|
|
|
# note that the dlllib.so will be added in lib/stublibs/
|
|
# dlllib.so lib.a liblib.a \
|
|
# dlllib.so liblib.a\
|
|
#todo: $(EXPORTSRC:%.mli=%.cmt) but must be guarded by having bin-annot
|