1 # Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
2 # Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller
3 # This file is part of Coccinelle.
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.
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.
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/>.
17 # The authors reserve the right to distribute this or future versions of
18 # Coccinelle under other licenses.
23 LEXER_SOURCES = lexer_cocci.mll
24 SCRIPT_LEXER_SOURCES = lexer_script.mll
25 PARSER_SOURCES = parser_cocci_menhir.mly
26 SOURCES = flag_parsing_cocci.ml type_cocci.ml ast_cocci.ml ast0_cocci.ml \
27 pretty_print_cocci.ml unparse_ast0.ml \
28 visitor_ast.ml visitor_ast0.ml compute_lines.ml comm_assoc.ml \
29 iso_pattern.ml iso_compile.ml single_statement.ml simple_assignments.ml \
30 ast0toast.ml check_meta.ml top_level.ml type_infer.ml test_exps.ml \
31 unitary_ast0.ml arity.ml index.ml context_neg.ml \
32 insert_plus.ml function_prototypes.ml \
33 unify_ast.ml semantic_cocci.ml data.ml free_vars.ml parse_aux.ml disjdistr.ml \
34 $(LEXER_SOURCES:.mll=.ml) $(PARSER_SOURCES:.mly=.ml) \
35 $(SCRIPT_LEXER_SOURCES:.mll=.ml) \
36 get_constants.ml get_constants2.ml parse_cocci.ml
38 LIBS=../commons/commons.cma ../globals/globals.cma
39 SYSLIBS = str.cma unix.cma
41 #MENHIR_PATH=$(shell ocamlfind query menhirLib)
42 MENHIR_PATH=../menhirlib
44 INCLUDES = -I ../commons -I ../commons/ocamlextra -I ../globals \
47 MENHIR=$(MENHIR_PATH)/menhirLib.cmo
48 MENHIRO=$(MENHIR_PATH)/menhirLib.cmx
52 OCAMLCFLAGS ?= -g -dtypes
53 OCAMLC =ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES)
54 OCAMLOPT = ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES)
55 OCAMLLEX = ocamllex$(OPTBIN)
56 OCAMLYACC= menhir --table
57 OCAMLDEP = ocamldep$(OPTBIN) $(INCLUDES)
61 OPTLIB=$(LIB:.cma=.cmxa)
63 GENERATED= $(LEXER_SOURCES:.mll=.ml) $(SCRIPT_LEXER_SOURCES:.mll=.ml) \
64 $(PARSER_SOURCES:.mly=.ml) $(PARSER_SOURCES:.mly=.mli)
65 OBJS = $(SOURCES:.ml=.cmo)
66 OPTOBJS = $(OBJS:.cmo=.cmx)
74 $(LIB): $(GENERATED) $(OBJS)
75 $(OCAMLC) -I $(MENHIR_PATH) -a -o $(LIB) $(MENHIR) $(OBJS)
78 $(OPTLIB): $(GENERATED) $(OPTOBJS)
79 $(OCAMLOPT) -I $(MENHIR_PATH) -a -o $(OPTLIB) $(MENHIRO) $(OPTOBJS)
82 $(EXEC): $(OBJS) main.cmo $(LIBS)
83 $(OCAMLC) -o $(EXEC) $(SYSLIBS) $(LIBS) $(OBJS) main.cmo
90 rm -f $(OPTLIB) $(LIB:.cma=.a)
97 .SUFFIXES: .ml .mli .cmo .cmi .cmx
108 $(LEXER_SOURCES:.mll=.ml) : $(LEXER_SOURCES)
109 $(OCAMLLEX) $(LEXER_SOURCES)
111 $(PARSER_SOURCES:.mly=.ml) $(PARSER_SOURCES:.mly=.mli) : $(PARSER_SOURCES)
112 $(OCAMLYACC) $(PARSER_SOURCES)
114 $(SCRIPT_LEXER_SOURCES:.mll=.ml): $(SCRIPT_LEXER_SOURCES)
115 $(OCAMLLEX) $(SCRIPT_LEXER_SOURCES)
120 # clean rule for others files
122 rm -f *.cm[iox] *.o *.annot
126 $(OCAMLDEP) *.mli *.ml > .depend
129 $(OCAMLDEP) *.mli *.ml > .depend
133 lexer_cocci.ml: lexer_cocci.mll
134 parser_cocci_menhir.ml: parser_cocci_menhir.mly lexer_cocci.mll
135 parser_cocci_menhir.mli: parser_cocci_menhir.mly lexer_cocci.mll
136 lexer_script.ml: lexer_script.mll