Coccinelle release-1.0.0-rc11
[bpt/coccinelle.git] / parsing_cocci / Makefile
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.
8 #
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.
12 #
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.
17 #
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/>.
20 #
21 # The authors reserve the right to distribute this or future versions of
22 # Coccinelle under other licenses.
23
24
25 -include ../Makefile.config
26
27 TARGET=cocci_parser
28
29 LEXER_SOURCES = lexer_cocci.mll
30 CLI_LEXER_SOURCES = lexer_cli.mll
31 SCRIPT_LEXER_SOURCES = lexer_script.mll
32 PARSER_SOURCES = parser_cocci_menhir.mly
33 SOURCES = flag_parsing_cocci.ml type_cocci.ml ast_cocci.ml ast0_cocci.ml \
34 pretty_print_cocci.ml unparse_ast0.ml visitor_ast0_types.ml \
35 visitor_ast.ml visitor_ast0.ml compute_lines.ml comm_assoc.ml \
36 iso_pattern.ml iso_compile.ml single_statement.ml simple_assignments.ml \
37 get_metas.ml ast0toast.ml check_meta.ml top_level.ml type_infer.ml \
38 test_exps.ml unitary_ast0.ml arity.ml index.ml context_neg.ml \
39 adjust_pragmas.ml insert_plus.ml function_prototypes.ml \
40 unify_ast.ml semantic_cocci.ml data.ml free_vars.ml safe_for_multi_decls.ml \
41 parse_aux.ml disjdistr.ml \
42 $(LEXER_SOURCES:.mll=.ml) $(PARSER_SOURCES:.mly=.ml) \
43 $(CLI_LEXER_SOURCES:.mll=.ml) $(SCRIPT_LEXER_SOURCES:.mll=.ml) \
44 get_constants2.ml id_utils.ml adjacency.ml parse_cocci.ml command_line.ml
45
46 LIBS=../commons/commons.cma ../globals/globals.cma
47 SYSLIBS = str.cma unix.cma
48
49 ifeq ("$(MENHIRDIR)","menhirlib")
50 MENHIR_PATH=../$(MENHIRDIR)
51 else
52 MENHIR_PATH=$(MENHIRDIR)
53 endif
54
55 INCLUDES = -I ../commons \
56 -I ../commons/ocamlextra \
57 -I ../globals \
58 -I $(MENHIR_PATH)
59
60 MENHIR=$(MENHIR_PATH)/menhirLib.cmo
61 MENHIRO=$(MENHIR_PATH)/menhirLib.cmx
62
63
64 # The Caml compilers.
65 OCAMLCFLAGS ?= -g -dtypes
66 OCAMLC =ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES)
67 OCAMLOPT = ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES)
68 OCAMLLEX = ocamllex$(OPTBIN)
69 OCAMLYACC= menhir --table
70 OCAMLDEP = ocamldep$(OPTBIN) #$(INCLUDES)
71 EXEC=$(TARGET).byte
72 EXEC=$(TARGET)
73 LIB=$(TARGET).cma
74 OPTLIB=$(LIB:.cma=.cmxa)
75
76 GENERATED= $(LEXER_SOURCES:.mll=.ml) \
77 $(CLI_LEXER_SOURCES:.mll=.ml) $(SCRIPT_LEXER_SOURCES:.mll=.ml) \
78 $(PARSER_SOURCES:.mly=.ml) $(PARSER_SOURCES:.mly=.mli)
79 OBJS = $(SOURCES:.ml=.cmo)
80 OPTOBJS = $(OBJS:.cmo=.cmx)
81
82
83 all: $(LIB)
84 local: $(EXEC)
85
86 all.opt: $(OPTLIB)
87
88 $(LIB): $(GENERATED) $(OBJS)
89 $(OCAMLC) -I $(MENHIR_PATH) -a -o $(LIB) $(MENHIR) $(OBJS)
90
91
92 $(OPTLIB): $(GENERATED) $(OPTOBJS)
93 $(OCAMLOPT) -I $(MENHIR_PATH) -a -o $(OPTLIB) $(MENHIRO) $(OPTOBJS)
94
95
96 $(EXEC): $(OBJS) main.cmo $(LIBS)
97 $(OCAMLC) -o $(EXEC) $(SYSLIBS) $(LIBS) $(OBJS) main.cmo
98
99
100
101
102 clean::
103 rm -f $(LIB)
104 rm -f $(OPTLIB) $(LIB:.cma=.a)
105 rm -f $(TARGET)
106
107
108
109
110 .SUFFIXES:
111 .SUFFIXES: .ml .mli .cmo .cmi .cmx
112
113 .ml.cmo:
114 $(OCAMLC) -c $<
115
116 .mli.cmi:
117 $(OCAMLC) -c $<
118
119 .ml.cmx:
120 $(OCAMLOPT) -c $<
121
122 $(LEXER_SOURCES:.mll=.ml) : $(LEXER_SOURCES)
123 $(OCAMLLEX) $(LEXER_SOURCES)
124
125 $(PARSER_SOURCES:.mly=.ml) $(PARSER_SOURCES:.mly=.mli) : $(PARSER_SOURCES)
126 $(OCAMLYACC) $(PARSER_SOURCES)
127
128 $(CLI_LEXER_SOURCES:.mll=.ml): $(CLI_LEXER_SOURCES)
129 $(OCAMLLEX) $(CLI_LEXER_SOURCES)
130
131 $(SCRIPT_LEXER_SOURCES:.mll=.ml): $(SCRIPT_LEXER_SOURCES)
132 $(OCAMLLEX) $(SCRIPT_LEXER_SOURCES)
133
134 distclean::
135 rm -f $(GENERATED)
136
137 # clean rule for others files
138 clean::
139 rm -f *.cm[iox] *.o *.annot
140 rm -f *~ .*~ #*#
141
142 distclean::
143 rm -f .depend
144
145 depend: $(GENERATED)
146 $(OCAMLDEP) *.mli *.ml > .depend
147
148 .depend:
149 $(OCAMLDEP) *.mli *.ml > .depend
150
151 -include .depend
152
153 lexer_cocci.ml: lexer_cocci.mll
154 parser_cocci_menhir.ml: parser_cocci_menhir.mly lexer_cocci.mll
155 parser_cocci_menhir.mli: parser_cocci_menhir.mly lexer_cocci.mll
156 lexer_script.ml: lexer_script.mll
157 lexer_cli.ml: lexer_cli.mll