##############################################################################
# Variables
##############################################################################
+
+# The main library
+ifneq ($(MAKECMDGOALS),distclean)
+include ../Makefile.config
+endif
+
TARGET=commons
# note: if you add a file (a .mli or .ml), dont forget to redo a 'make depend'
-MYSRC=common.ml common_extra.ml \
- interfaces.ml objet.ml \
- ocollection.ml \
- seti.ml \
- oset.ml oassoc.ml osequence.ml ograph.ml \
- oseti.ml oseth.ml osetb.ml osetpt.ml \
- oassocb.ml oassoch.ml oassoc_buffer.ml oassocid.ml \
- oarray.ml \
- ograph2way.ml ograph_extended.ml \
- ofullcommon.ml \
- glimpse.ml
+MYSRC= commands.ml \
+ common.ml common_extra.ml \
+ interfaces.ml objet.ml \
+ ocollection.ml \
+ seti.ml \
+ oset.ml oassoc.ml osequence.ml ograph.ml \
+ ocollection/oseti.ml \
+ ocollection/oseth.ml \
+ ocollection/osetb.ml \
+ ocollection/osetpt.ml \
+ ocollection/oassocb.ml \
+ ocollection/oassoch.ml \
+ ocollection/oassoc_buffer.ml \
+ ocollection/oassoc_cache.ml \
+ ocollection/oassocid.ml \
+ oarray.ml \
+ ocollection/ograph2way.ml \
+ ograph_simple.ml ograph_extended.ml \
+ glimpse.ml parser_combinators.ml
# src from other authors, got from the web or caml hump
-SRC=ocamlextra/dumper.ml
-SRC+=ocamlextra/ANSITerminal.ml
+SRC=ocamlextra/dumper.ml
+SRC+=ocamlextra/ANSITerminal.ml
SRC+=ocamlextra/setb.ml ocamlextra/mapb.ml # defunctorized version of standard set/map
SRC+=ocamlextra/setPt.ml
SRC+=$(MYSRC)
SRC+=ocamlextra/enum.ml ocamlextra/dynArray.ml
-SRC+=ocamlextra/parser_combinators.ml
-SRC+=ocamlextra/suffix_tree.ml ocamlextra/suffix_tree_ext.ml
+SRC+=ocamlextra/suffix_tree.ml ocamlextra/suffix_tree_ext.ml
-SYSLIBS=str.cma unix.cma
+SYSLIBS=str.cma bigarray.cma unix.cma
-INCLUDEDIRS=ocamlextra
-SUBDIR=ocamlextra
+INCLUDEDIRS=ocamlextra ocollection
+SUBDIRS=ocamlextra ocollection
#-----------------------------------------------------------------------------
# Other common (thin wrapper) libraries
#-----------------------------------------------------------------------------
+#format: XXXSRC, XXXINCLUDE, XXXSYSLIBS
+
#gdbm
-MYGDBMSRC=oassocdbm.ml
+MYGDBMSRC=ocollection/oassocdbm.ml
GDBMSYSLIBS=dbm.cma
-#berkeley db
+#berkeley db (ocamlbdb)
+MYBDBSRC=ocollection/oassocbdb.ml ocollection/oassocbdb_string.ml
BDBINCLUDES=-I ../ocamlbdb
-MYBDBSRC=oassocbdb.ml
BDBSYSLIBS=bdb.cma
-#ocamlgtk
-GUIINCLUDES=-I +lablgtk2 -I +lablgtksourceview -I ../ocamlgtk/src
+#lablgtk (ocamlgtk)
MYGUISRC=gui.ml
+GUIINCLUDES=-I +lablgtk2 -I +lablgtksourceview -I ../ocamlgtk/src
GUISYSLIBS=lablgtk.cma lablgtksourceview.cma
-#pycaml
-PYINCLUDES=-I ../ocamlpython -I ../../ocamlpython
+#pycaml (ocamlpython)
MYPYSRC=python.ml
+PYINCLUDES=-I ../ocamlpython -I ../../ocamlpython
PYSYSLIBS=python.cma
#ocamlmpi
-MPIINCLUDES=-I ../ocamlmpi -I ../../ocamlmpi -I +ocamlmpi
-MYMPISRC=distribution.ml
-MPISYSLIBS=mpi.cma
-
-#ocamlmpi
-MPIINCLUDES=-I ../ocamlmpi -I ../../ocamlmpi -I +ocamlmpi
MYMPISRC=distribution.ml
+MPIINCLUDES=-I ../ocamlmpi -I ../../ocamlmpi -I +ocamlmpi
MPISYSLIBS=mpi.cma
+#binprot
+MYBINSRC=bin_common.ml
+BININCLUDES=-I ../ocamltarzan/lib-binprot -I ../../ocamltarzan/lib-binprot
#-----------------------------------------------------------------------------
# Other stuff
#-----------------------------------------------------------------------------
#backtrace
-BACKTRACEINCLUDES=-I $(shell ocamlc -where)
MYBACKTRACESRC=backtrace.ml
+BACKTRACEINCLUDES=-I $(shell $(OCAMLC) -where)
+
##############################################################################
# Generic variables
# This flag can also be used in subdirectories so don't change its name here.
# For profiling use: -p -inline 0
-OPTFLAGS=
-#-thread
+OCAMLCFLAGS ?= -g
+OPTFLAGS ?= -g
-# The OPTBIN variable is here to allow to use ocamlc.opt instead of
+# 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
+# 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
-
-OCAMLCFLAGS ?= -g -dtypes
+OPTBIN ?= #.opt
# 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)
-
-# if need C code
-OCAMLMKLIB=ocamlmklib
-CC=gcc
+OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES)
+OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(INCLUDES)
+OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDES)
+OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES)
##############################################################################
# Top rules
OPTOBJS = $(SRC:.ml=.cmx)
+ifneq ($(FEATURE_OCAMLBUILD),yes)
all: $(LIB)
-all.opt: $(OPTLIB)
+all.opt:
+ @$(MAKE) $(OPTLIB) BUILD_OPT=yes
opt: all.opt
top: $(TARGET).top
$(LIB): $(OBJS)
- $(OCAMLC) -a -o $@ $^
+ $(OCAMLC_CMD) -a -o $@ $^
$(OPTLIB): $(OPTOBJS)
- $(OCAMLOPT) -a -o $@ $^
+ $(OCAMLOPT_CMD) -a -o $@ $^
$(TARGET).top: $(OBJS)
- $(OCAMLMKTOP) -o $@ $(SYSLIBS) $^
+ $(OCAMLMKTOP_CMD) -o $@ $(SYSLIBS) $^
clean::
rm -f $(TARGET).top
+else
+all:
+ cd .. && $(OCAMLBUILD) commons/commons.cma
+all.opt:
+ cd .. && $(OCAMLBUILD) commons/commons.cmxa
+clean::
+ cd .. && $(OCAMLBUILD) -clean
+endif
##############################################################################
# Other commons libs target
all_libs: gdbm bdb gui mpi backtrace
+#-----------------------------------------------------------------------------
gdbm: commons_gdbm.cma
gdbm.opt: commons_gdbm.cmxa
commons_gdbm.cma: $(MYGDBMSRC:.ml=.cmo)
- $(OCAMLC) -a -o $@ $^
+ $(OCAMLC_CMD) -a -o $@ $^
commons_gdbm.cmxa: $(MYGDBMSRC:.ml=.cmx)
- $(OCAMLOPT) -a -o $@ $^
+ $(OCAMLOPT_CMD) -a -o $@ $^
-bdb:
+#-----------------------------------------------------------------------------
+bdb:
$(MAKE) INCLUDESEXTRA="$(BDBINCLUDES)" commons_bdb.cma
-bdb.opt:
+bdb.opt:
$(MAKE) INCLUDESEXTRA="$(BDBINCLUDES)" commons_bdb.cmxa
commons_bdb.cma: $(MYBDBSRC:.ml=.cmo)
- $(OCAMLC) -a -o $@ $^
+ $(OCAMLC_CMD) -a -o $@ $^
commons_bdb.cmxa: $(MYBDBSRC:.ml=.cmx)
- $(OCAMLOPT) -a -o $@ $^
+ $(OCAMLOPT_CMD) -a -o $@ $^
+#-----------------------------------------------------------------------------
gui:
$(MAKE) INCLUDESEXTRA="$(GUIINCLUDES)" commons_gui.cma
gui.opt:
$(MAKE) INCLUDESEXTRA="$(GUIINCLUDES)" commons_gui.cmxa
commons_gui.cma: $(MYGUISRC:.ml=.cmo)
- $(OCAMLC) -a -o $@ $^
+ $(OCAMLC_CMD) -a -o $@ $^
commons_gui.cmxa: $(MYGUISRC:.ml=.cmx)
- $(OCAMLOPT) -a -o $@ $^
+ $(OCAMLOPT_CMD) -a -o $@ $^
-mpi:
+#-----------------------------------------------------------------------------
+mpi:
$(MAKE) INCLUDESEXTRA="$(MPIINCLUDES)" commons_mpi.cma
-mpi.opt:
+mpi.opt:
$(MAKE) INCLUDESEXTRA="$(MPIINCLUDES)" commons_mpi.cmxa
commons_mpi.cma: $(MYMPISRC:.ml=.cmo)
- $(OCAMLC) -a -o $@ $^
+ $(OCAMLC_CMD) -a -o $@ $^
commons_mpi.cmxa: $(MYMPISRC:.ml=.cmx)
- $(OCAMLOPT) -a -o $@ $^
+ $(OCAMLOPT_CMD) -a -o $@ $^
#alias
distribution: mpi
-python:
+#-----------------------------------------------------------------------------
+python:
$(MAKE) INCLUDESEXTRA="$(PYINCLUDES)" commons_python.cma
-python.opt:
+python.opt:
$(MAKE) INCLUDESEXTRA="$(PYINCLUDES)" commons_python.cmxa
commons_python.cma: $(MYPYSRC:.ml=.cmo)
- $(OCAMLC) -a -o $@ $^
+ $(OCAMLC_CMD) -a -o $@ $^
commons_python.cmxa: $(MYPYSRC:.ml=.cmx)
- $(OCAMLOPT) -a -o $@ $^
-
+ $(OCAMLOPT_CMD) -a -o $@ $^
+#-----------------------------------------------------------------------------
backtrace: commons_backtrace.cma
backtrace.opt: commons_backtrace.cmxa
rm -f dllcommons_backtrace.so
+
+#-----------------------------------------------------------------------------
+binprot:
+ $(MAKE) INCLUDESEXTRA="$(BININCLUDES)" commons_bin.cma
+binprot.opt:
+ $(MAKE) INCLUDESEXTRA="$(BININCLUDES)" commons_bin.cmxa
+
+commons_bin.cma: $(MYBINSRC:.ml=.cmo)
+ $(OCAMLC_CMD) -a -o $@ $^
+
+commons_bin.cmxa: $(MYBINSRC:.ml=.cmx)
+ $(OCAMLOPT_CMD) -a -o $@ $^
+
+##############################################################################
+# The global "features" lib wrapper
+##############################################################################
+
+features: commons_features.cma
+features.opt: commons_features.cmxa
+
+commons_features.cma: features.cmo
+ $(OCAMLC_CMD) -a -o $@ $^
+
+commons_features.cmxa: features.cmx
+ $(OCAMLOPT_CMD) -a -o $@ $^
+
+
##############################################################################
# Developer rules
##############################################################################
otags -no-mli-tags -r .
clean::
- rm -f gmon.out
+ rm -f gmon.out
forprofiling:
$(MAKE) OPTFLAGS="-p -inline 0 " opt
.SUFFIXES: .ml .mli .cmo .cmi .cmx
.ml.cmo:
- $(OCAMLC) -c $<
+ $(OCAMLC_CMD) -c $<
.mli.cmi:
- $(OCAMLC) -c $<
+ $(OCAMLC_CMD) -c $<
.ml.cmx:
- $(OCAMLOPT) -c $<
+ $(OCAMLOPT_CMD) -c $<
clean::
rm -f *.cm[iox] *.o *.a *.cma *.cmxa *.annot
- rm -f *~ .*~ #*#
+ rm -f *~ .*~ #*#
clean::
- rm -f $(SUBDIR)/*.cm[iox] $(SUBDIR)/*.o $(SUBDIR)/*.a
- rm -f $(SUBDIR)/*.cma $(SUBDIR)/*.cmxa $(SUBDIR)/*.annot
- rm -f $(SUBDIR)/*~ $(SUBDIR)/.*~ #*#
+ for i in $(SUBDIRS); do (cd $$i; \
+ rm -f *.cm[iox] *.o *.a *.cma *.cmxa *.annot *~ .*~ ; \
+ cd ..; ) \
+ done
+ rm -f .depend
-depend:
- $(OCAMLDEP) *.mli *.ml $(SUBDIR)/*.ml $(SUBDIR)/*.mli > .depend
+distclean: clean
+ rm -f commands.ml
-distclean::
- rm -f .depend
+.PHONEY: depend
+.depend depend:
+ $(OCAMLDEP_CMD) *.mli *.ml > .depend
+ for i in $(SUBDIRS); do $(OCAMLDEP_CMD) $$i/*.ml $$i/*.mli >> .depend; done
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(MAKECMDGOALS),distclean)
+ifneq ($(FEATURE_OCAMLBUILD),yes)
-include .depend
+endif
+endif
+endif
+
+include ../Makefile.common