37ebde50ed6818bd1ef81cf96978f2fcb4a7db8d
[bpt/coccinelle.git] / parsing_cocci / Makefile
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
23 -include ../Makefile.config
24
25 TARGET=cocci_parser
26
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
41
42 LIBS=../commons/commons.cma ../globals/globals.cma
43 SYSLIBS = str.cma unix.cma
44
45 ifeq ("$(MENHIRDIR)","menhirlib")
46 MENHIR_PATH=../$(MENHIRDIR)
47 else
48 MENHIR_PATH=$(MENHIRDIR)
49 endif
50
51 INCLUDES = -I ../commons -I ../commons/ocamlextra -I ../globals \
52 -I $(MENHIR_PATH)
53
54 MENHIR=$(MENHIR_PATH)/menhirLib.cmo
55 MENHIRO=$(MENHIR_PATH)/menhirLib.cmx
56
57
58 # The Caml compilers.
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)
65 EXEC=$(TARGET).byte
66 EXEC=$(TARGET)
67 LIB=$(TARGET).cma
68 OPTLIB=$(LIB:.cma=.cmxa)
69
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)
74
75
76 all: $(LIB)
77 local: $(EXEC)
78
79 all.opt: $(OPTLIB)
80
81 $(LIB): $(GENERATED) $(OBJS)
82 $(OCAMLC) -I $(MENHIR_PATH) -a -o $(LIB) $(MENHIR) $(OBJS)
83
84
85 $(OPTLIB): $(GENERATED) $(OPTOBJS)
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
95 clean::
96 rm -f $(LIB)
97 rm -f $(OPTLIB) $(LIB:.cma=.a)
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
124 distclean::
125 rm -f $(GENERATED)
126
127 # clean rule for others files
128 clean::
129 rm -f *.cm[iox] *.o *.annot
130 rm -f *~ .*~ #*#
131
132 distclean::
133 rm -f .depend
134
135 depend: $(GENERATED)
136 $(OCAMLDEP) *.mli *.ml > .depend
137
138 .depend:
139 $(OCAMLDEP) *.mli *.ml > .depend
140
141 -include .depend
142
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