Release coccinelle-0.2.0
[bpt/coccinelle.git] / parsing_cocci / Makefile
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
21 -include ../Makefile.config
22
23 TARGET=cocci_parser
24
25 LEXER_SOURCES = lexer_cocci.mll
26 SCRIPT_LEXER_SOURCES = lexer_script.mll
27 PARSER_SOURCES = parser_cocci_menhir.mly
28 SOURCES = flag_parsing_cocci.ml type_cocci.ml ast_cocci.ml ast0_cocci.ml \
29 pretty_print_cocci.ml unparse_ast0.ml visitor_ast0_types.ml \
30 visitor_ast.ml visitor_ast0.ml compute_lines.ml comm_assoc.ml \
31 iso_pattern.ml iso_compile.ml single_statement.ml simple_assignments.ml \
32 ast0toast.ml check_meta.ml top_level.ml type_infer.ml \
33 test_exps.ml unitary_ast0.ml arity.ml index.ml context_neg.ml \
34 adjust_pragmas.ml insert_plus.ml function_prototypes.ml \
35 unify_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) \
38 get_constants.ml get_constants2.ml adjacency.ml parse_cocci.ml
39
40 LIBS=../commons/commons.cma ../globals/globals.cma
41 SYSLIBS = str.cma unix.cma
42
43 #MENHIR_PATH=$(shell ocamlfind query menhirLib)
44 MENHIR_PATH=../menhirlib
45
46 INCLUDES = -I ../commons -I ../commons/ocamlextra -I ../globals \
47 -I $(MENHIR_PATH)
48
49 MENHIR=$(MENHIR_PATH)/menhirLib.cmo
50 MENHIRO=$(MENHIR_PATH)/menhirLib.cmx
51
52
53 # The Caml compilers.
54 OCAMLCFLAGS ?= -g -dtypes
55 OCAMLC =ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES)
56 OCAMLOPT = ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES)
57 OCAMLLEX = ocamllex$(OPTBIN)
58 OCAMLYACC= menhir --table
59 OCAMLDEP = ocamldep$(OPTBIN) $(INCLUDES)
60 EXEC=$(TARGET).byte
61 EXEC=$(TARGET)
62 LIB=$(TARGET).cma
63 OPTLIB=$(LIB:.cma=.cmxa)
64
65 GENERATED= $(LEXER_SOURCES:.mll=.ml) $(SCRIPT_LEXER_SOURCES:.mll=.ml) \
66 $(PARSER_SOURCES:.mly=.ml) $(PARSER_SOURCES:.mly=.mli)
67 OBJS = $(SOURCES:.ml=.cmo)
68 OPTOBJS = $(OBJS:.cmo=.cmx)
69
70
71 all: $(LIB)
72 local: $(EXEC)
73
74 all.opt: $(OPTLIB)
75
76 $(LIB): $(GENERATED) $(OBJS)
77 $(OCAMLC) -I $(MENHIR_PATH) -a -o $(LIB) $(MENHIR) $(OBJS)
78
79
80 $(OPTLIB): $(GENERATED) $(OPTOBJS)
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
90 clean::
91 rm -f $(LIB)
92 rm -f $(OPTLIB) $(LIB:.cma=.a)
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
119 distclean::
120 rm -f $(GENERATED)
121
122 # clean rule for others files
123 clean::
124 rm -f *.cm[iox] *.o *.annot
125 rm -f *~ .*~ #*#
126
127 distclean::
128 rm -f .depend
129
130 depend: $(GENERATED)
131 $(OCAMLDEP) *.mli *.ml > .depend
132
133 .depend:
134 $(OCAMLDEP) *.mli *.ml > .depend
135
136 -include .depend
137
138 lexer_cocci.ml: lexer_cocci.mll
139 parser_cocci_menhir.ml: parser_cocci_menhir.mly lexer_cocci.mll
140 parser_cocci_menhir.mli: parser_cocci_menhir.mly lexer_cocci.mll
141 lexer_script.ml: lexer_script.mll