X-Git-Url: http://git.hcoop.net/bpt/coccinelle.git/blobdiff_plain/91eba41f0f6608eba3499d37eeaf609f7060fffe..abad11c5570b7b9bbae5ff92b3050cf68fe3fd14:/commons/Makefile diff --git a/commons/Makefile b/commons/Makefile index b30a105..0ad2077 100644 --- a/commons/Makefile +++ b/commons/Makefile @@ -1,31 +1,45 @@ ############################################################################## # 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 \ - ocollection/oseti.ml ocollection/oseth.ml ocollection/osetb.ml ocollection/osetpt.ml \ - ocollection/oassocb.ml ocollection/oassoch.ml ocollection/oassoc_buffer.ml ocollection/oassocid.ml \ - oarray.ml \ - ocollection/ograph2way.ml ograph_extended.ml \ - ofullcommon.ml \ - glimpse.ml parser_combinators.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/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 ocollection SUBDIRS=ocamlextra ocollection @@ -34,45 +48,45 @@ SUBDIRS=ocamlextra ocollection # Other common (thin wrapper) libraries #----------------------------------------------------------------------------- +#format: XXXSRC, XXXINCLUDE, XXXSYSLIBS + #gdbm MYGDBMSRC=ocollection/oassocdbm.ml GDBMSYSLIBS=dbm.cma #berkeley db (ocamlbdb) -BDBINCLUDES=-I ../ocamlbdb MYBDBSRC=ocollection/oassocbdb.ml ocollection/oassocbdb_string.ml +BDBINCLUDES=-I ../ocamlbdb BDBSYSLIBS=bdb.cma #lablgtk (ocamlgtk) -GUIINCLUDES=-I +lablgtk2 -I +lablgtksourceview -I ../ocamlgtk/src MYGUISRC=gui.ml +GUIINCLUDES=-I +lablgtk2 -I +lablgtksourceview -I ../ocamlgtk/src GUISYSLIBS=lablgtk.cma lablgtksourceview.cma #pycaml (ocamlpython) -PYINCLUDES=-I ../ocamlpython -I ../../ocamlpython MYPYSRC=python.ml +PYINCLUDES=-I ../ocamlpython -I ../../ocamlpython PYSYSLIBS=python.cma #ocamlmpi -MPIINCLUDES=-I ../ocamlmpi -I ../../ocamlmpi -I +ocamlmpi MYMPISRC=distribution.ml +MPIINCLUDES=-I ../ocamlmpi -I ../../ocamlmpi -I +ocamlmpi MPISYSLIBS=mpi.cma - -#----------------------------------------------------------------------------- -#pcre -#REGEXPINCLUDES=-I +pcre -REGEXPINCLUDES=-I ../ocamlpcre/lib -MYREGEXPSRC=regexp.ml +#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 @@ -86,28 +100,20 @@ INCLUDES=$(INCLUDEDIRS:%=-I %) $(INCLUDESEXTRA) # 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 @@ -119,22 +125,32 @@ OBJS = $(SRC:.ml=.cmo) 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 @@ -147,23 +163,23 @@ 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 $@ $^ @@ -174,24 +190,24 @@ 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 @@ -200,31 +216,17 @@ distribution.opt: mpi.opt #----------------------------------------------------------------------------- -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 $@ $^ - - -#----------------------------------------------------------------------------- -regexp: - $(MAKE) INCLUDESEXTRA="$(REGEXPINCLUDES)" commons_regexp.cma -regexp.opt: - $(MAKE) INCLUDESEXTRA="$(REGEXPINCLUDES)" commons_regexp.cmxa - -commons_regexp.cma: $(MYREGEXPSRC:.ml=.cmo) - $(OCAMLC) -a -o $@ $^ - -commons_regexp.cmxa: $(MYREGEXPSRC:.ml=.cmx) - $(OCAMLOPT) -a -o $@ $^ - + $(OCAMLOPT_CMD) -a -o $@ $^ #----------------------------------------------------------------------------- backtrace: commons_backtrace.cma @@ -243,6 +245,33 @@ clean:: 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 ############################################################################## @@ -251,7 +280,7 @@ tags: otags -no-mli-tags -r . clean:: - rm -f gmon.out + rm -f gmon.out forprofiling: $(MAKE) OPTFLAGS="-p -inline 0 " opt @@ -274,27 +303,37 @@ dependencygraph2: .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:: 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 > .depend - for i in $(SUBDIRS); do ocamldep $$i/*.ml $$i/*.mli >> .depend; done +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