permit multiline comments and strings in macros
[bpt/coccinelle.git] / parsing_c / Makefile
index 68b0c5a..9f9e794 100644 (file)
@@ -1,22 +1,26 @@
-
--include ../Makefile.config
+ifneq ($(MAKECMDGOALS),distclean)
+include ../Makefile.config
+endif
 
 ##############################################################################
 # Variables
 ##############################################################################
 TARGET=parsing_c
 
-
-# - type_cocci.ml ast_cocci.ml  # + unparse_hrule 
-SRC= flag_parsing_c.ml parsing_stat.ml \
- token_c.ml ast_c.ml control_flow_c.ml type_c.ml \
+# - type_cocci.ml ast_cocci.ml  # + unparse_hrule
+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 \
ast_to_flow.ml \
control_flow_c_build.ml \
  pretty_print_c.ml \
  semantic_c.ml lexer_parser.ml parser_c.ml lexer_c.ml \
- token_helpers.ml parsing_hacks.ml \
+ token_helpers.ml token_views_c.ml \
+ cpp_token_c.ml  \
+ parsing_hacks.ml \
+ cpp_analysis_c.ml \
  unparse_cocci.ml unparse_c.ml unparse_hrule.ml  \
- parse_c.ml \
+ parsing_recovery_c.ml parsing_consistency_c.ml \
+ parse_c.ml type_c.ml \
  cpp_ast_c.ml \
  type_annoter_c.ml comment_annotater_c.ml \
  compare_c.ml \
@@ -24,37 +28,35 @@ SRC= flag_parsing_c.ml parsing_stat.ml \
 
 
 
-# ast_cocci.ml and unparse_cocci.ml should be deleted in the futur
-# to make parsing_c really independent of coccinelle. 
+# 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 
+# old: parsing_c now depends on cocci_parser because in addition to decorate
 # the token in Ast_c with some parse info, we now also make some place to
 # welcome some mcodekind of Ast_cocci.
 LIBS=../commons/commons.cma ../globals/globals.cma \
      ../parsing_cocci/cocci_parser.cma
 
-INCLUDES= -I ../commons -I ../commons/ocamlextra -I ../commons/ocollection \
-  -I ../globals -I  ../parsing_cocci 
+INCLUDESDEP= -I ../commons -I ../commons/ocamlextra -I ../commons/ocollection \
+  -I ../globals -I  ../parsing_cocci
 
-#LIBS=../commons/commons.cma
-#INCLUDES= -I ../commons
-SYSLIBS= str.cma unix.cma 
+INCLUDES=$(INCLUDESDEP) $(TARZANINCLUDE)
+
+SYSLIBS= str.cma unix.cma num.cma
 
 ##############################################################################
 # Generic variables
 ##############################################################################
 
-#for warning:  -w A 
+#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) $(INCLUDES)
-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)
@@ -63,35 +65,42 @@ 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
 
-
-
 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
 
 
 ##############################################################################
@@ -120,6 +129,10 @@ locindiv:
        wc -l ast_c.ml
        wc -l parse_c.ml
 
+##############################################################################
+# Literate Programming rules
+##############################################################################
+
 
 ##############################################################################
 # Generic rules
@@ -128,23 +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
-clean::
        rm -f *~ .*~ gmon.out #*#
+       rm -f .depend
 
-beforedepend::
+distclean: clean
 
-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