| 1 | ifneq ($(MAKECMDGOALS),distclean) |
| 2 | include ../Makefile.config |
| 3 | endif |
| 4 | |
| 5 | ############################################################################## |
| 6 | # Variables |
| 7 | ############################################################################## |
| 8 | TARGET=parsing_c |
| 9 | |
| 10 | # - type_cocci.ml ast_cocci.ml # + unparse_hrule |
| 11 | SRC= flag_parsing_c.ml parsing_stat.ml \ |
| 12 | token_c.ml ast_c.ml control_flow_c.ml \ |
| 13 | visitor_c.ml lib_parsing_c.ml \ |
| 14 | control_flow_c_build.ml \ |
| 15 | pretty_print_c.ml \ |
| 16 | semantic_c.ml lexer_parser.ml parser_c.ml lexer_c.ml \ |
| 17 | token_helpers.ml token_views_c.ml \ |
| 18 | cpp_token_c.ml \ |
| 19 | parsing_hacks.ml \ |
| 20 | cpp_analysis_c.ml \ |
| 21 | unparse_cocci.ml unparse_c.ml unparse_hrule.ml \ |
| 22 | parsing_recovery_c.ml parsing_consistency_c.ml \ |
| 23 | parse_c.ml type_c.ml \ |
| 24 | cpp_ast_c.ml \ |
| 25 | type_annoter_c.ml comment_annotater_c.ml \ |
| 26 | compare_c.ml \ |
| 27 | test_parsing_c.ml |
| 28 | |
| 29 | |
| 30 | |
| 31 | # ast_cocci.ml and unparse_cocci.ml should be deleted in the future |
| 32 | # to make parsing_c really independent of coccinelle. |
| 33 | # control_flow_c have also coccinelle dependencies. |
| 34 | # old: parsing_c now depends on cocci_parser because in addition to decorate |
| 35 | # the token in Ast_c with some parse info, we now also make some place to |
| 36 | # welcome some mcodekind of Ast_cocci. |
| 37 | LIBS=../commons/commons.cma ../globals/globals.cma \ |
| 38 | ../parsing_cocci/cocci_parser.cma |
| 39 | |
| 40 | INCLUDESDEP= -I ../commons -I ../commons/ocamlextra -I ../commons/ocollection \ |
| 41 | -I ../globals -I ../parsing_cocci |
| 42 | |
| 43 | INCLUDES=$(INCLUDESDEP) $(TARZANINCLUDE) |
| 44 | |
| 45 | SYSLIBS= str.cma unix.cma num.cma |
| 46 | |
| 47 | ############################################################################## |
| 48 | # Generic variables |
| 49 | ############################################################################## |
| 50 | |
| 51 | #for warning: -w A |
| 52 | #for profiling: -p -inline 0 with OCAMLOPT |
| 53 | OCAMLCFLAGS ?= -g |
| 54 | OPTFLAGS ?= -g |
| 55 | |
| 56 | OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES) |
| 57 | OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(INCLUDES) |
| 58 | OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDESDEP) |
| 59 | OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES) |
| 60 | |
| 61 | OBJS = $(SRC:.ml=.cmo) |
| 62 | OPTOBJS = $(SRC:.ml=.cmx) |
| 63 | |
| 64 | |
| 65 | ############################################################################## |
| 66 | # Top rules |
| 67 | ############################################################################## |
| 68 | all: $(TARGET).cma |
| 69 | all.opt: |
| 70 | @$(MAKE) $(TARGET).cmxa BUILD_OPT=yes |
| 71 | |
| 72 | $(TARGET).cma: $(OBJS) |
| 73 | $(OCAMLC_CMD) -a -o $(TARGET).cma $(OBJS) |
| 74 | |
| 75 | $(TARGET).cmxa: $(OPTOBJS) $(LIBS:.cma=.cmxa) |
| 76 | $(OCAMLOPT_CMD) -a -o $(TARGET).cmxa $(OPTOBJS) |
| 77 | |
| 78 | $(TARGET).top: $(OBJS) $(LIBS) |
| 79 | $(OCAMLMKTOP_CMD) -o $(TARGET).top $(SYSLIBS) $(LIBS) $(OBJS) |
| 80 | |
| 81 | clean:: |
| 82 | rm -f $(TARGET).top |
| 83 | |
| 84 | lexer_c.ml: lexer_c.mll |
| 85 | $(OCAMLLEX) $< |
| 86 | clean:: |
| 87 | rm -f lexer_c.ml |
| 88 | |
| 89 | parser_c.ml parser_c.mli: parser_c.mly |
| 90 | $(OCAMLYACC) -v $< |
| 91 | clean:: |
| 92 | rm -f parser_c.ml parser_c.mli parser_c.output |
| 93 | |
| 94 | |
| 95 | ############################################################################## |
| 96 | # Pad's rules |
| 97 | ############################################################################## |
| 98 | # visitor_c.ml lib_parsing_c.ml \ |
| 99 | # type_annoter_c.ml \ |
| 100 | # statistics_c.ml \ |
| 101 | # pretty_print_c.ml unparse_c.ml \ |
| 102 | # test_parsing_c.ml |
| 103 | #toreput: compare_c.ml ast_to_flow.ml |
| 104 | |
| 105 | COREPARSING= flag_parsing_c.ml parsing_stat.ml \ |
| 106 | ast_cocci.ml \ |
| 107 | ast_c.ml control_flow_c.ml \ |
| 108 | semantic_c.ml lexer_parser.ml parser_c.mly lexer_c.mll \ |
| 109 | token_helpers.ml parsing_hacks.ml parse_c.ml \ |
| 110 | |
| 111 | locparsing: |
| 112 | wc -l $(COREPARSING) |
| 113 | |
| 114 | locindiv: |
| 115 | wc -l lexer_c.mll |
| 116 | wc -l parser_c.mly |
| 117 | wc -l parsing_hacks.ml |
| 118 | wc -l ast_c.ml |
| 119 | wc -l parse_c.ml |
| 120 | |
| 121 | ############################################################################## |
| 122 | # Literate Programming rules |
| 123 | ############################################################################## |
| 124 | |
| 125 | |
| 126 | ############################################################################## |
| 127 | # Generic rules |
| 128 | ############################################################################## |
| 129 | |
| 130 | .SUFFIXES: .ml .mli .cmo .cmi .cmx |
| 131 | |
| 132 | .ml.cmo: |
| 133 | $(OCAMLC_CMD) -c $< |
| 134 | .mli.cmi: |
| 135 | $(OCAMLC_CMD) -c $< |
| 136 | .ml.cmx: |
| 137 | $(OCAMLOPT_CMD) -c $< |
| 138 | |
| 139 | clean:: |
| 140 | rm -f *.cm[ioxa] *.o *.a *.cmxa *.annot |
| 141 | rm -f *~ .*~ gmon.out #*# |
| 142 | rm -f .depend |
| 143 | |
| 144 | distclean: clean |
| 145 | |
| 146 | .depend depend: lexer_c.ml parser_c.ml parser_c.mli |
| 147 | $(OCAMLDEP_CMD) *.mli *.ml > .depend |
| 148 | |
| 149 | ifneq ($(MAKECMDGOALS),clean) |
| 150 | ifneq ($(MAKECMDGOALS),distclean) |
| 151 | -include .depend |
| 152 | endif |
| 153 | endif |
| 154 | |
| 155 | include ../Makefile.common |