-
--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
-TARZANINCLUDE=-I ../ocamlsexp
-endif
-
-
-
# - 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 \
- $(TARZANSRC) \
visitor_c.ml lib_parsing_c.ml \
control_flow_c_build.ml \
pretty_print_c.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
LIBS=../commons/commons.cma ../globals/globals.cma \
../parsing_cocci/cocci_parser.cma
-INCLUDES= -I ../commons -I ../commons/ocamlextra -I ../commons/ocollection \
- $(TARZANINCLUDE) \
+INCLUDESDEP= -I ../commons -I ../commons/ocamlextra -I ../commons/ocollection \
-I ../globals -I ../parsing_cocci
-#LIBS=../commons/commons.cma
-#INCLUDES= -I ../commons
+INCLUDES=$(INCLUDESDEP) $(TARZANINCLUDE)
+
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) $(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)
##############################################################################
# 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
$(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
##############################################################################
.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