Commit | Line | Data |
---|---|---|
17ba0788 C |
1 | # Copyright 2012, INRIA |
2 | # Julia Lawall, Gilles Muller | |
3 | # Copyright 2010-2011, INRIA, University of Copenhagen | |
f537ebc4 C |
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 | ||
0708f913 C |
25 | -include ../Makefile.config |
26 | ||
34e49164 C |
27 | TARGET=cocci_parser |
28 | ||
29 | LEXER_SOURCES = lexer_cocci.mll | |
993936c0 | 30 | CLI_LEXER_SOURCES = lexer_cli.mll |
34e49164 C |
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 \ | |
b1b2de81 | 34 | pretty_print_cocci.ml unparse_ast0.ml visitor_ast0_types.ml \ |
34e49164 C |
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 \ | |
17ba0788 | 37 | get_metas.ml ast0toast.ml check_meta.ml top_level.ml type_infer.ml \ |
978fd7e5 | 38 | test_exps.ml unitary_ast0.ml arity.ml index.ml context_neg.ml \ |
0708f913 | 39 | adjust_pragmas.ml insert_plus.ml function_prototypes.ml \ |
690d68d1 C |
40 | unify_ast.ml semantic_cocci.ml data.ml free_vars.ml safe_for_multi_decls.ml \ |
41 | parse_aux.ml disjdistr.ml \ | |
34e49164 | 42 | $(LEXER_SOURCES:.mll=.ml) $(PARSER_SOURCES:.mly=.ml) \ |
993936c0 C |
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 | |
34e49164 | 45 | |
b1b2de81 | 46 | LIBS=../commons/commons.cma ../globals/globals.cma |
34e49164 C |
47 | SYSLIBS = str.cma unix.cma |
48 | ||
90aeb998 C |
49 | ifeq ("$(MENHIRDIR)","menhirlib") |
50 | MENHIR_PATH=../$(MENHIRDIR) | |
51 | else | |
52 | MENHIR_PATH=$(MENHIRDIR) | |
53 | endif | |
34e49164 | 54 | |
993936c0 C |
55 | INCLUDES = -I ../commons \ |
56 | -I ../commons/ocamlextra \ | |
57 | -I ../globals \ | |
58 | -I $(MENHIR_PATH) | |
34e49164 C |
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 | |
993936c0 | 70 | OCAMLDEP = ocamldep$(OPTBIN) #$(INCLUDES) |
34e49164 C |
71 | EXEC=$(TARGET).byte |
72 | EXEC=$(TARGET) | |
73 | LIB=$(TARGET).cma | |
74 | OPTLIB=$(LIB:.cma=.cmxa) | |
75 | ||
993936c0 C |
76 | GENERATED= $(LEXER_SOURCES:.mll=.ml) \ |
77 | $(CLI_LEXER_SOURCES:.mll=.ml) $(SCRIPT_LEXER_SOURCES:.mll=.ml) \ | |
34e49164 C |
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 | ||
34e49164 C |
88 | $(LIB): $(GENERATED) $(OBJS) |
89 | $(OCAMLC) -I $(MENHIR_PATH) -a -o $(LIB) $(MENHIR) $(OBJS) | |
90 | ||
91 | ||
b1b2de81 | 92 | $(OPTLIB): $(GENERATED) $(OPTOBJS) |
34e49164 C |
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) | |
b1b2de81 | 104 | rm -f $(OPTLIB) $(LIB:.cma=.a) |
34e49164 C |
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 | ||
993936c0 C |
128 | $(CLI_LEXER_SOURCES:.mll=.ml): $(CLI_LEXER_SOURCES) |
129 | $(OCAMLLEX) $(CLI_LEXER_SOURCES) | |
130 | ||
34e49164 C |
131 | $(SCRIPT_LEXER_SOURCES:.mll=.ml): $(SCRIPT_LEXER_SOURCES) |
132 | $(OCAMLLEX) $(SCRIPT_LEXER_SOURCES) | |
133 | ||
708f4980 | 134 | distclean:: |
34e49164 C |
135 | rm -f $(GENERATED) |
136 | ||
137 | # clean rule for others files | |
138 | clean:: | |
139 | rm -f *.cm[iox] *.o *.annot | |
b1b2de81 C |
140 | rm -f *~ .*~ #*# |
141 | ||
142 | distclean:: | |
143 | rm -f .depend | |
34e49164 C |
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 | |
993936c0 | 157 | lexer_cli.ml: lexer_cli.mll |