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