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