Release coccinelle-0.2.5-rc1
[bpt/coccinelle.git] / parsing_cocci / Makefile
1 # Copyright 2010, INRIA, University of Copenhagen
2 # Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
3 # Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
4 # Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
5 # This file is part of Coccinelle.
6 #
7 # Coccinelle is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, according to version 2 of the License.
10 #
11 # Coccinelle is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
18 #
19 # The authors reserve the right to distribute this or future versions of
20 # Coccinelle under other licenses.
21
22
23 -include ../Makefile.config
24
25 TARGET=cocci_parser
26
27 LEXER_SOURCES = lexer_cocci.mll
28 SCRIPT_LEXER_SOURCES = lexer_script.mll
29 PARSER_SOURCES = parser_cocci_menhir.mly
30 SOURCES = flag_parsing_cocci.ml type_cocci.ml ast_cocci.ml ast0_cocci.ml \
31 pretty_print_cocci.ml unparse_ast0.ml visitor_ast0_types.ml \
32 visitor_ast.ml visitor_ast0.ml compute_lines.ml comm_assoc.ml \
33 iso_pattern.ml iso_compile.ml single_statement.ml simple_assignments.ml \
34 ast0toast.ml check_meta.ml top_level.ml type_infer.ml \
35 test_exps.ml unitary_ast0.ml arity.ml index.ml context_neg.ml \
36 adjust_pragmas.ml insert_plus.ml function_prototypes.ml \
37 unify_ast.ml semantic_cocci.ml data.ml free_vars.ml safe_for_multi_decls.ml \
38 parse_aux.ml disjdistr.ml \
39 $(LEXER_SOURCES:.mll=.ml) $(PARSER_SOURCES:.mly=.ml) \
40 $(SCRIPT_LEXER_SOURCES:.mll=.ml) \
41 get_constants2.ml id_utils.ml adjacency.ml parse_cocci.ml
42
43 LIBS=../commons/commons.cma ../globals/globals.cma
44 SYSLIBS = str.cma unix.cma
45
46 ifeq ("$(MENHIRDIR)","menhirlib")
47 MENHIR_PATH=../$(MENHIRDIR)
48 else
49 MENHIR_PATH=$(MENHIRDIR)
50 endif
51
52 INCLUDES = -I ../commons -I ../commons/ocamlextra -I ../globals \
53 -I $(MENHIR_PATH)
54
55 MENHIR=$(MENHIR_PATH)/menhirLib.cmo
56 MENHIRO=$(MENHIR_PATH)/menhirLib.cmx
57
58
59 # The Caml compilers.
60 OCAMLCFLAGS ?= -g -dtypes
61 OCAMLC =ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES)
62 OCAMLOPT = ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES)
63 OCAMLLEX = ocamllex$(OPTBIN)
64 OCAMLYACC= menhir --table
65 OCAMLDEP = ocamldep$(OPTBIN) $(INCLUDES)
66 EXEC=$(TARGET).byte
67 EXEC=$(TARGET)
68 LIB=$(TARGET).cma
69 OPTLIB=$(LIB:.cma=.cmxa)
70
71 GENERATED= $(LEXER_SOURCES:.mll=.ml) $(SCRIPT_LEXER_SOURCES:.mll=.ml) \
72 $(PARSER_SOURCES:.mly=.ml) $(PARSER_SOURCES:.mly=.mli)
73 OBJS = $(SOURCES:.ml=.cmo)
74 OPTOBJS = $(OBJS:.cmo=.cmx)
75
76
77 all: $(LIB)
78 local: $(EXEC)
79
80 all.opt: $(OPTLIB)
81
82 $(LIB): $(GENERATED) $(OBJS)
83 $(OCAMLC) -I $(MENHIR_PATH) -a -o $(LIB) $(MENHIR) $(OBJS)
84
85
86 $(OPTLIB): $(GENERATED) $(OPTOBJS)
87 $(OCAMLOPT) -I $(MENHIR_PATH) -a -o $(OPTLIB) $(MENHIRO) $(OPTOBJS)
88
89
90 $(EXEC): $(OBJS) main.cmo $(LIBS)
91 $(OCAMLC) -o $(EXEC) $(SYSLIBS) $(LIBS) $(OBJS) main.cmo
92
93
94
95
96 clean::
97 rm -f $(LIB)
98 rm -f $(OPTLIB) $(LIB:.cma=.a)
99 rm -f $(TARGET)
100
101
102
103
104 .SUFFIXES:
105 .SUFFIXES: .ml .mli .cmo .cmi .cmx
106
107 .ml.cmo:
108 $(OCAMLC) -c $<
109
110 .mli.cmi:
111 $(OCAMLC) -c $<
112
113 .ml.cmx:
114 $(OCAMLOPT) -c $<
115
116 $(LEXER_SOURCES:.mll=.ml) : $(LEXER_SOURCES)
117 $(OCAMLLEX) $(LEXER_SOURCES)
118
119 $(PARSER_SOURCES:.mly=.ml) $(PARSER_SOURCES:.mly=.mli) : $(PARSER_SOURCES)
120 $(OCAMLYACC) $(PARSER_SOURCES)
121
122 $(SCRIPT_LEXER_SOURCES:.mll=.ml): $(SCRIPT_LEXER_SOURCES)
123 $(OCAMLLEX) $(SCRIPT_LEXER_SOURCES)
124
125 distclean::
126 rm -f $(GENERATED)
127
128 # clean rule for others files
129 clean::
130 rm -f *.cm[iox] *.o *.annot
131 rm -f *~ .*~ #*#
132
133 distclean::
134 rm -f .depend
135
136 depend: $(GENERATED)
137 $(OCAMLDEP) *.mli *.ml > .depend
138
139 .depend:
140 $(OCAMLDEP) *.mli *.ml > .depend
141
142 -include .depend
143
144 lexer_cocci.ml: lexer_cocci.mll
145 parser_cocci_menhir.ml: parser_cocci_menhir.mly lexer_cocci.mll
146 parser_cocci_menhir.mli: parser_cocci_menhir.mly lexer_cocci.mll
147 lexer_script.ml: lexer_script.mll