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