Commit | Line | Data |
---|---|---|
0708f913 C |
1 | # Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen |
2 | # Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller | |
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 | TARGET=cocci_parser | |
22 | ||
23 | LEXER_SOURCES = lexer_cocci.mll | |
24 | SCRIPT_LEXER_SOURCES = lexer_script.mll | |
25 | PARSER_SOURCES = parser_cocci_menhir.mly | |
26 | SOURCES = flag_parsing_cocci.ml type_cocci.ml ast_cocci.ml ast0_cocci.ml \ | |
27 | pretty_print_cocci.ml unparse_ast0.ml \ | |
28 | visitor_ast.ml visitor_ast0.ml compute_lines.ml comm_assoc.ml \ | |
29 | iso_pattern.ml iso_compile.ml single_statement.ml simple_assignments.ml \ | |
30 | ast0toast.ml check_meta.ml top_level.ml type_infer.ml test_exps.ml \ | |
31 | unitary_ast0.ml arity.ml index.ml context_neg.ml \ | |
32 | insert_plus.ml function_prototypes.ml \ | |
33 | unify_ast.ml semantic_cocci.ml data.ml free_vars.ml parse_aux.ml disjdistr.ml \ | |
34 | $(LEXER_SOURCES:.mll=.ml) $(PARSER_SOURCES:.mly=.ml) \ | |
35 | $(SCRIPT_LEXER_SOURCES:.mll=.ml) \ | |
36 | get_constants.ml get_constants2.ml parse_cocci.ml | |
37 | ||
38 | LIBS=../commons/commons.cma ../globals/globals.cma | |
39 | SYSLIBS = str.cma unix.cma | |
40 | ||
41 | #MENHIR_PATH=$(shell ocamlfind query menhirLib) | |
42 | MENHIR_PATH=../menhirlib | |
43 | ||
44 | INCLUDES = -I ../commons -I ../commons/ocamlextra -I ../globals \ | |
45 | -I $(MENHIR_PATH) | |
46 | ||
47 | MENHIR=$(MENHIR_PATH)/menhirLib.cmo | |
48 | MENHIRO=$(MENHIR_PATH)/menhirLib.cmx | |
49 | ||
50 | ||
51 | # The Caml compilers. | |
52 | OCAMLCFLAGS ?= -g -dtypes | |
53 | OCAMLC =ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES) | |
54 | OCAMLOPT = ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES) | |
55 | OCAMLLEX = ocamllex$(OPTBIN) | |
56 | OCAMLYACC= menhir --table | |
57 | OCAMLDEP = ocamldep$(OPTBIN) #$(INCLUDES) | |
58 | EXEC=$(TARGET).byte | |
59 | EXEC=$(TARGET) | |
60 | LIB=$(TARGET).cma | |
61 | OPTLIB=$(LIB:.cma=.cmxa) | |
62 | ||
63 | GENERATED= $(LEXER_SOURCES:.mll=.ml) $(SCRIPT_LEXER_SOURCES:.mll=.ml) \ | |
64 | $(PARSER_SOURCES:.mly=.ml) $(PARSER_SOURCES:.mly=.mli) | |
65 | OBJS = $(SOURCES:.ml=.cmo) | |
66 | OPTOBJS = $(OBJS:.cmo=.cmx) | |
67 | ||
68 | ||
69 | all: $(LIB) | |
70 | local: $(EXEC) | |
71 | ||
72 | all.opt: $(OPTLIB) | |
73 | ||
74 | $(LIB): $(GENERATED) $(OBJS) | |
75 | $(OCAMLC) -I $(MENHIR_PATH) -a -o $(LIB) $(MENHIR) $(OBJS) | |
76 | ||
77 | ||
78 | $(OPTLIB): $(GENERATED) $(OPTOBJS) | |
79 | $(OCAMLOPT) -I $(MENHIR_PATH) -a -o $(OPTLIB) $(MENHIRO) $(OPTOBJS) | |
80 | ||
81 | ||
82 | $(EXEC): $(OBJS) main.cmo $(LIBS) | |
83 | $(OCAMLC) -o $(EXEC) $(SYSLIBS) $(LIBS) $(OBJS) main.cmo | |
84 | ||
85 | ||
86 | ||
87 | ||
88 | clean:: | |
89 | rm -f $(LIB) | |
90 | rm -f $(OPTLIB) $(LIB:.cma=.a) | |
91 | rm -f $(TARGET) | |
92 | ||
93 | ||
94 | ||
95 | ||
96 | .SUFFIXES: | |
97 | .SUFFIXES: .ml .mli .cmo .cmi .cmx | |
98 | ||
99 | .ml.cmo: | |
100 | $(OCAMLC) -c $< | |
101 | ||
102 | .mli.cmi: | |
103 | $(OCAMLC) -c $< | |
104 | ||
105 | .ml.cmx: | |
106 | $(OCAMLOPT) -c $< | |
107 | ||
108 | $(LEXER_SOURCES:.mll=.ml) : $(LEXER_SOURCES) | |
109 | $(OCAMLLEX) $(LEXER_SOURCES) | |
110 | ||
111 | $(PARSER_SOURCES:.mly=.ml) $(PARSER_SOURCES:.mly=.mli) : $(PARSER_SOURCES) | |
112 | $(OCAMLYACC) $(PARSER_SOURCES) | |
113 | ||
114 | $(SCRIPT_LEXER_SOURCES:.mll=.ml): $(SCRIPT_LEXER_SOURCES) | |
115 | $(OCAMLLEX) $(SCRIPT_LEXER_SOURCES) | |
116 | ||
117 | clean:: | |
118 | rm -f $(GENERATED) | |
119 | ||
120 | # clean rule for others files | |
121 | clean:: | |
122 | rm -f *.cm[iox] *.o *.annot | |
123 | rm -f *~ .*~ #*# | |
124 | ||
125 | depend: $(GENERATED) | |
126 | $(OCAMLDEP) *.mli *.ml > .depend | |
127 | ||
128 | .depend: | |
129 | $(OCAMLDEP) *.mli *.ml > .depend | |
130 | ||
131 | -include .depend | |
132 | ||
133 | lexer_cocci.ml: lexer_cocci.mll | |
134 | parser_cocci_menhir.ml: parser_cocci_menhir.mly lexer_cocci.mll | |
135 | parser_cocci_menhir.mli: parser_cocci_menhir.mly lexer_cocci.mll | |
136 | lexer_script.ml: lexer_script.mll |