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