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.
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.
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.
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/>.
19 # The authors reserve the right to distribute this or future versions of
20 # Coccinelle under other licenses.
23 -include ..
/Makefile.config
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 parse_aux.ml disjdistr.ml \
38 $(LEXER_SOURCES
:.mll
=.ml
) $(PARSER_SOURCES
:.mly
=.ml
) \
39 $(SCRIPT_LEXER_SOURCES
:.mll
=.ml
) \
40 get_constants2.ml adjacency.ml parse_cocci.ml
42 LIBS
=..
/commons
/commons.cma ..
/globals
/globals.cma
43 SYSLIBS
= str.cma unix.cma
45 ifeq ("$(MENHIRDIR)","menhirlib")
46 MENHIR_PATH
=..
/$(MENHIRDIR
)
48 MENHIR_PATH
=$(MENHIRDIR
)
51 INCLUDES
= -I ..
/commons
-I ..
/commons
/ocamlextra
-I ..
/globals \
54 MENHIR
=$(MENHIR_PATH
)/menhirLib.cmo
55 MENHIRO
=$(MENHIR_PATH
)/menhirLib.cmx
59 OCAMLCFLAGS ?
= -g
-dtypes
60 OCAMLC
=ocamlc
$(OPTBIN
) $(OCAMLCFLAGS
) $(INCLUDES
)
61 OCAMLOPT
= ocamlopt
$(OPTBIN
) $(OPTFLAGS
) $(INCLUDES
)
62 OCAMLLEX
= ocamllex
$(OPTBIN
)
63 OCAMLYACC
= menhir
--table
64 OCAMLDEP
= ocamldep
$(OPTBIN
) $(INCLUDES
)
68 OPTLIB
=$(LIB
:.cma
=.cmxa
)
70 GENERATED
= $(LEXER_SOURCES
:.mll
=.ml
) $(SCRIPT_LEXER_SOURCES
:.mll
=.ml
) \
71 $(PARSER_SOURCES
:.mly
=.ml
) $(PARSER_SOURCES
:.mly
=.mli
)
72 OBJS
= $(SOURCES
:.ml
=.cmo
)
73 OPTOBJS
= $(OBJS
:.cmo
=.cmx
)
81 $(LIB
): $(GENERATED
) $(OBJS
)
82 $(OCAMLC
) -I
$(MENHIR_PATH
) -a
-o
$(LIB
) $(MENHIR
) $(OBJS
)
85 $(OPTLIB
): $(GENERATED
) $(OPTOBJS
)
86 $(OCAMLOPT
) -I
$(MENHIR_PATH
) -a
-o
$(OPTLIB
) $(MENHIRO
) $(OPTOBJS
)
89 $(EXEC
): $(OBJS
) main.cmo
$(LIBS
)
90 $(OCAMLC
) -o
$(EXEC
) $(SYSLIBS
) $(LIBS
) $(OBJS
) main.cmo
97 rm -f
$(OPTLIB
) $(LIB
:.cma
=.a
)
104 .SUFFIXES
: .ml .mli .cmo .cmi .cmx
115 $(LEXER_SOURCES
:.mll
=.ml
) : $(LEXER_SOURCES
)
116 $(OCAMLLEX
) $(LEXER_SOURCES
)
118 $(PARSER_SOURCES
:.mly
=.ml
) $(PARSER_SOURCES
:.mly
=.mli
) : $(PARSER_SOURCES
)
119 $(OCAMLYACC
) $(PARSER_SOURCES
)
121 $(SCRIPT_LEXER_SOURCES
:.mll
=.ml
): $(SCRIPT_LEXER_SOURCES
)
122 $(OCAMLLEX
) $(SCRIPT_LEXER_SOURCES
)
127 # clean rule for others files
129 rm -f
*.cm
[iox
] *.o
*.annot
136 $(OCAMLDEP
) *.mli
*.ml
> .depend
139 $(OCAMLDEP
) *.mli
*.ml
> .depend
143 lexer_cocci.ml
: lexer_cocci.mll
144 parser_cocci_menhir.ml
: parser_cocci_menhir.mly lexer_cocci.mll
145 parser_cocci_menhir.mli
: parser_cocci_menhir.mly lexer_cocci.mll
146 lexer_script.ml
: lexer_script.mll