permit multiline comments and strings in macros
[bpt/coccinelle.git] / parsing_c / Makefile
index 7446ef7..9f9e794 100644 (file)
@@ -1,26 +1,14 @@
-
--include ../Makefile.config
+ifneq ($(MAKECMDGOALS),distclean)
+include ../Makefile.config
+endif
 
 ##############################################################################
 # Variables
 ##############################################################################
 TARGET=parsing_c
 
--include ../Makefile.config
-
-# ifeq ($(FEATURE_TARZAN), 1)
-# TARZANSRC=sexp_ast_c.ml
-# ifeq ("$(SEXPDIR)","ocamlsexp")
-# TARZANINCLUDE=-I ../$(SEXPDIR)
-# else
-# TARZANINCLUDE=-I $(SEXPDIR)
-# endif # Use local ocamlsexp
-# endif # FEATURE_TARZAN
-
-
-
 # - type_cocci.ml ast_cocci.ml  # + unparse_hrule
-SRC= flag_parsing_c.ml parsing_stat.ml \
+SRC= token_annot.ml flag_parsing_c.ml parsing_stat.ml \
  token_c.ml ast_c.ml control_flow_c.ml \
  visitor_c.ml lib_parsing_c.ml \
  control_flow_c_build.ml \
@@ -40,7 +28,7 @@ SRC= flag_parsing_c.ml parsing_stat.ml \
 
 
 
-# ast_cocci.ml and unparse_cocci.ml should be deleted in the futur
+# ast_cocci.ml and unparse_cocci.ml should be deleted in the future
 # to make parsing_c really independent of coccinelle.
 # control_flow_c have also coccinelle dependencies.
 # old: parsing_c now depends on cocci_parser because in addition to decorate
@@ -54,8 +42,6 @@ INCLUDESDEP= -I ../commons -I ../commons/ocamlextra -I ../commons/ocollection \
 
 INCLUDES=$(INCLUDESDEP) $(TARZANINCLUDE)
 
-#LIBS=../commons/commons.cma
-#INCLUDES= -I ../commons
 SYSLIBS= str.cma unix.cma num.cma
 
 ##############################################################################
@@ -64,15 +50,13 @@ SYSLIBS= str.cma unix.cma num.cma
 
 #for warning:  -w A
 #for profiling:  -p -inline 0   with OCAMLOPT
-OCAMLCFLAGS ?= -g -dtypes
-
-OCAMLC=ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES)
-OCAMLOPT=ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES)
-OCAMLLEX=ocamllex$(OPTBIN) #-ml
-OCAMLYACC=ocamlyacc -v
-OCAMLDEP=ocamldep$(OPTBIN) $(INCLUDESDEP)
-OCAMLMKTOP=ocamlmktop -g -custom $(INCLUDES)
+OCAMLCFLAGS ?= -g
+OPTFLAGS ?= -g
 
+OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES)
+OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(INCLUDES)
+OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDESDEP)
+OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES)
 
 OBJS = $(SRC:.ml=.cmo)
 OPTOBJS = $(SRC:.ml=.cmx)
@@ -81,17 +65,19 @@ OPTOBJS = $(SRC:.ml=.cmx)
 ##############################################################################
 # Top rules
 ##############################################################################
+ifneq ($(FEATURE_OCAMLBUILD),yes)
 all: $(TARGET).cma
-all.opt: $(TARGET).cmxa
+all.opt:
+       @$(MAKE) $(TARGET).cmxa BUILD_OPT=yes
 
 $(TARGET).cma: $(OBJS)
-       $(OCAMLC) -a -o $(TARGET).cma $(OBJS)
+       $(OCAMLC_CMD) -a -o $(TARGET).cma $(OBJS)
 
 $(TARGET).cmxa: $(OPTOBJS) $(LIBS:.cma=.cmxa)
-       $(OCAMLOPT) -a -o $(TARGET).cmxa $(OPTOBJS)
+       $(OCAMLOPT_CMD) -a -o $(TARGET).cmxa $(OPTOBJS)
 
 $(TARGET).top: $(OBJS) $(LIBS)
-       $(OCAMLMKTOP) -o $(TARGET).top $(SYSLIBS) $(LIBS) $(OBJS)
+       $(OCAMLMKTOP_CMD) -o $(TARGET).top $(SYSLIBS) $(LIBS) $(OBJS)
 
 clean::
        rm -f $(TARGET).top
@@ -100,14 +86,21 @@ lexer_c.ml: lexer_c.mll
        $(OCAMLLEX) $<
 clean::
        rm -f lexer_c.ml
-beforedepend:: lexer_c.ml
-
 
 parser_c.ml parser_c.mli: parser_c.mly
-       $(OCAMLYACC) $<
+       $(OCAMLYACC) -v $<
 clean::
        rm -f parser_c.ml parser_c.mli parser_c.output
-beforedepend:: parser_c.ml parser_c.mli
+else
+all:
+       cd .. && $(OCAMLBUILD) parsing_c/parsing_c.cma
+
+all.opt:
+       cd .. && $(OCAMLBUILD) parsing_c/parsing_c.cmxa
+
+clean::
+       cd .. && $(OCAMLBUILD) -clean
+endif
 
 
 ##############################################################################
@@ -148,28 +141,28 @@ locindiv:
 .SUFFIXES: .ml .mli .cmo .cmi .cmx
 
 .ml.cmo:
-       $(OCAMLC) -c $<
+       $(OCAMLC_CMD) -c $<
 .mli.cmi:
-       $(OCAMLC) -c $<
+       $(OCAMLC_CMD) -c $<
 .ml.cmx:
-       $(OCAMLOPT) -c $<
-
-.ml.mldepend:
-       $(OCAMLC) -i $<
+       $(OCAMLOPT_CMD) -c $<
 
 clean::
        rm -f *.cm[ioxa] *.o *.a *.cmxa *.annot
        rm -f *~ .*~ gmon.out #*#
-
-distclean::
        rm -f .depend
 
-beforedepend::
+distclean: clean
 
-distclean::
-       rm -f .depend
-
-depend:: beforedepend
-       $(OCAMLDEP) *.mli *.ml    > .depend
+.depend depend: lexer_c.ml parser_c.ml parser_c.mli
+       $(OCAMLDEP_CMD) *.mli *.ml > .depend
 
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(MAKECMDGOALS),distclean)
+ifneq ($(FEATURE_OCAMLBUILD),yes)
 -include .depend
+endif
+endif
+endif
+
+include ../Makefile.common