Coccinelle release 1.0.0-rc13
[bpt/coccinelle.git] / globals / Makefile
index 226bd5d..af2432f 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright 2012, INRIA
+# Julia Lawall, Gilles Muller
+# Copyright 2010-2011, INRIA, University of Copenhagen
+# Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
 # Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
 # Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
 # This file is part of Coccinelle.
 # Coccinelle under other licenses.
 
 
-
--include ../Makefile.config
+ifneq ($(MAKECMDGOALS),distclean)
+include ../Makefile.config
+endif
 
 ##############################################################################
 # Variables
 ##############################################################################
 TARGET=globals
 
-SRC= flag.ml config.ml
+OCAMLCFLAGS ?= -g -dtypes
+OPTFLAGS ?= -g
+
+SRC=config.ml flag.ml iteration.ml $(REGEXP_FILE) regexp.ml
 
 LIBS=
-INCLUDES=
+INCLUDEDIRS= ../commons $(PCREDIR)
 
 ##############################################################################
 # Generic variables
 ##############################################################################
-OCAMLCFLAGS ?= -g -dtypes
-OCAMLC =ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES)
-OCAMLOPT = ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES)
-OCAMLDEP = ocamldep$(OPTBIN) $(INCLUDES)
-OCAMLMKTOP=ocamlmktop -g -custom $(INCLUDES)
+
+INCLUDES=$(INCLUDEDIRS:%=-I %)
+OCAMLC_CMD=$(OCAMLC) -thread $(OCAMLCFLAGS) $(INCLUDES)
+OCAMLOPT_CMD=$(OCAMLOPT) -thread $(OPTFLAGS) $(INCLUDES)
+OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDES)
+OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES)
 
 OBJS= $(SRC:.ml=.cmo)
 OPTOBJS= $(SRC:.ml=.cmx)
 
-
 ##############################################################################
 # Top rules
 ##############################################################################
 all: $(TARGET).cma
 
-all.opt: $(TARGET).cmxa
-
-$(TARGET).cma: $(OBJS) $(LIBS)
-       $(OCAMLC) -a -o $(TARGET).cma $(OBJS)
-
-$(TARGET).cmxa: $(OPTOBJS) $(LIBS:.cma=.cmxa)
-       $(OCAMLOPT) -a -o $(TARGET).cmxa $(OPTOBJS)
+all.opt:
+       @$(MAKE) $(TARGET).cmxa BUILD_OPT=yes
 
+$(TARGET).cma: $(LIBS) $(OBJS)
+       $(OCAMLC_CMD) -a -o $(TARGET).cma $(OBJS)
 
+$(TARGET).cmxa: $(LIBS:.cma=.cmxa) $(OPTOBJS)
+       $(OCAMLOPT_CMD) -a -o $(TARGET).cmxa $(OPTOBJS)
 
 ##############################################################################
 # Developer rules
@@ -65,29 +72,30 @@ $(TARGET).cmxa: $(OPTOBJS) $(LIBS:.cma=.cmxa)
 .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 $<
 
 .ml.mldepend:
-       $(OCAMLC) -i $<
+       $(OCAMLC_CMD) -i $<
 
-clean::
+clean:
        rm -f *.cm[ioxa] *.o *.a *.cmxa *.annot
        rm -f *~ .*~ gmon.out #*#
-
-distclean::
        rm -f .depend
 
-beforedepend::
+distclean: clean
 
-depend:: beforedepend
-       $(OCAMLDEP) *.mli *.ml    > .depend
+.PHONEY: depend
+.depend depend:
+       $(OCAMLDEP_CMD) *.mli *.ml > .depend
 
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(MAKECMDGOALS),distclean)
 -include .depend
+endif
+endif
 
-
-
-
+include ../Makefile.common