1 # Copyright 2012, INRIA
2 # Julia Lawall, Gilles Muller
3 # Copyright 2010-2011, INRIA, University of Copenhagen
4 # Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
5 # Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
6 # Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
7 # This file is part of Coccinelle.
9 # Coccinelle is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, according to version 2 of the License.
13 # Coccinelle is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Coccinelle. If not, see <http://www.gnu.org/licenses/>.
21 # The authors reserve the right to distribute this or future versions of
22 # Coccinelle under other licenses.
25 ifneq ($(MAKECMDGOALS
),distclean)
26 include ..
/Makefile.config
31 LEXER_SOURCES
= lexer_cocci.mll
32 CLI_LEXER_SOURCES
= lexer_cli.mll
33 SCRIPT_LEXER_SOURCES
= lexer_script.mll
34 PARSER_SOURCES
= parser_cocci_menhir.mly
35 SOURCES
= flag_parsing_cocci.ml type_cocci.ml ast_cocci.ml ast0_cocci.ml \
36 pretty_print_cocci.ml unparse_ast0.ml visitor_ast0_types.ml \
37 visitor_ast.ml visitor_ast0.ml compute_lines.ml comm_assoc.ml \
38 iso_pattern.ml iso_compile.ml single_statement.ml simple_assignments.ml \
39 get_metas.ml ast0toast.ml check_meta.ml top_level.ml type_infer.ml \
40 test_exps.ml unitary_ast0.ml arity.ml index.ml context_neg.ml \
41 adjust_pragmas.ml insert_plus.ml function_prototypes.ml \
42 unify_ast.ml semantic_cocci.ml data.ml free_vars.ml safe_for_multi_decls.ml \
43 parse_aux.ml disjdistr.ml \
44 $(LEXER_SOURCES
:.mll
=.ml
) $(PARSER_SOURCES
:.mly
=.ml
) \
45 $(CLI_LEXER_SOURCES
:.mll
=.ml
) $(SCRIPT_LEXER_SOURCES
:.mll
=.ml
) \
46 get_constants2.ml id_utils.ml adjacency.ml parse_cocci.ml command_line.ml
48 LIBS
=..
/commons
/commons.cma ..
/globals
/globals.cma
49 SYSLIBS
= str.cma unix.cma
51 INCLUDES
= -I ..
/commons \
52 -I ..
/commons
/ocamlextra \
56 MENHIRMOD
=menhirLib.cmo
57 MENHIROMOD
=menhirLib.cmx
60 OCAMLCFLAGS ?
= -g
-dtypes
64 OPTLIB
=$(LIB
:.cma
=.cmxa
)
66 GENERATED
= $(LEXER_SOURCES
:.mll
=.ml
) \
67 $(CLI_LEXER_SOURCES
:.mll
=.ml
) $(SCRIPT_LEXER_SOURCES
:.mll
=.ml
) \
68 $(PARSER_SOURCES
:.mly
=.ml
) $(PARSER_SOURCES
:.mly
=.mli
)
69 OBJS
= $(SOURCES
:.ml
=.cmo
)
70 OPTOBJS
= $(OBJS
:.cmo
=.cmx
)
78 $(LIB
): $(GENERATED
) $(OBJS
)
79 $(OCAMLC
) $(OCAMLCFLAGS
) $(INCLUDES
) -I
$(MENHIRDIR
) -a
-o
$(LIB
) $(MENHIRMOD
) $(OBJS
)
82 $(OPTLIB
): $(GENERATED
) $(OPTOBJS
)
83 $(OCAMLOPT
) $(OPTFLAGS
) $(INCLUDES
) -I
$(MENHIRDIR
) -a
-o
$(OPTLIB
) $(MENHIROMOD
) $(OPTOBJS
)
86 $(EXEC
): $(OBJS
) main.cmo
$(LIBS
)
87 $(OCAMLC
) $(OCAMLCFLAGS
) $(INCLUDES
) -o
$(EXEC
) $(SYSLIBS
) $(LIBS
) $(OBJS
) main.cmo
91 rm -f
$(OPTLIB
) $(LIB
:.cma
=.a
)
96 .SUFFIXES
: .ml .mli .cmo .cmi .cmx
99 $(OCAMLC
) $(OCAMLCFLAGS
) $(INCLUDES
) -c
$<
102 $(OCAMLC
) $(OCAMLCFLAGS
) $(INCLUDES
) -c
$<
105 $(OCAMLOPT
) $(OPTFLAGS
) $(INCLUDES
) -c
$<
107 $(LEXER_SOURCES
:.mll
=.ml
) : $(LEXER_SOURCES
)
108 $(OCAMLLEX
) $(LEXER_SOURCES
)
110 $(PARSER_SOURCES
:.mly
=.ml
) $(PARSER_SOURCES
:.mly
=.mli
) : $(PARSER_SOURCES
)
111 $(MENHIR
) --ocamlc
"${OCAMLC}" --ocamldep
"${OCAMLDEP}" --table
--base parser_cocci_menhir
$(PARSER_SOURCES
)
113 $(CLI_LEXER_SOURCES
:.mll
=.ml
): $(CLI_LEXER_SOURCES
)
114 $(OCAMLLEX
) $(CLI_LEXER_SOURCES
)
116 $(SCRIPT_LEXER_SOURCES
:.mll
=.ml
): $(SCRIPT_LEXER_SOURCES
)
117 $(OCAMLLEX
) $(SCRIPT_LEXER_SOURCES
)
120 @echo cleaning generated parsers and lexers
123 # clean rule for others files
125 rm -f
*.cm
[iox
] *.o
*.annot
131 .depend depend
: $(GENERATED
)
132 $(OCAMLDEP
) *.mli
*.ml
> .depend
134 lexer_cocci.ml
: lexer_cocci.mll
135 parser_cocci_menhir.ml
: parser_cocci_menhir.mly lexer_cocci.mll
136 parser_cocci_menhir.mli
: parser_cocci_menhir.mly lexer_cocci.mll
137 lexer_script.ml
: lexer_script.mll
138 lexer_cli.ml
: lexer_cli.mll
140 ifneq ($(MAKECMDGOALS
),clean)
141 ifneq ($(MAKECMDGOALS
),distclean)