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 | ||
abad11c5 | 25 | |
34e49164 C |
26 | ############################################################################# |
27 | # Configuration section | |
28 | ############################################################################# | |
feec80c3 C |
29 | ifneq ($(MAKECMDGOALS),distclean) |
30 | include ../Makefile.config | |
31 | endif | |
34e49164 C |
32 | |
33 | ############################################################################## | |
34 | # Variables | |
35 | ############################################################################## | |
36 | TARGET=coccipython | |
37 | ||
755320b0 C |
38 | OCAMLCFLAGS ?= -g |
39 | OPTFLAGS ?= -g | |
d6ce1786 | 40 | |
17ba0788 | 41 | SOURCES= pycocci_aux.ml $(PYCOCCI_FILE) pycocci.ml |
34e49164 | 42 | |
413ffc02 C |
43 | INCLUDEDIRS_LOCAL = ../commons ../commons/ocamlextra ../globals \ |
44 | ../parsing_c ../parsing_cocci | |
45 | ||
413ffc02 | 46 | INCLUDEDIRS = $(INCLUDEDIRS_LOCAL) $(PYCAMLDIR) |
34e49164 | 47 | |
90aeb998 | 48 | SYSLIBS = str.cma unix.cma pycaml.cma |
b1b2de81 | 49 | LIBS=../commons/commons.cma ../globals/globals.cma |
34e49164 | 50 | |
34e49164 C |
51 | ############################################################################## |
52 | # Generic variables | |
53 | ############################################################################## | |
54 | ||
55 | INCLUDES=$(INCLUDEDIRS:%=-I %) $(INCLUDESEXTRA) | |
413ffc02 | 56 | INCLUDES_DEPEND=$(INCLUDEDIRS_LOCAL:%=-I %) $(INCLUDESEXTRA) |
34e49164 C |
57 | |
58 | ############################################################################## | |
59 | # Generic ocaml variables | |
60 | ############################################################################## | |
61 | ||
62 | # The Caml compilers. | |
755320b0 C |
63 | OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(INCLUDES) |
64 | OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(INCLUDES) | |
feec80c3 C |
65 | OCAMLDEP_CMD=$(OCAMLDEP) $(INCLUDES_DEPEND) |
66 | OCAMLMKTOP_CMD=$(OCAMLMKTOP) -g -custom $(INCLUDES) | |
34e49164 C |
67 | |
68 | ############################################################################## | |
69 | # Top rules | |
70 | ############################################################################## | |
71 | ||
72 | EXEC=$(TARGET).byte | |
73 | LIB=$(TARGET).cma | |
74 | OPTLIB=$(LIB:.cma=.cmxa) | |
75 | ||
76 | CTLEXEC=$(CTLTARGET) | |
77 | ||
78 | OBJS = $(SOURCES:.ml=.cmo) | |
79 | OPTOBJS = $(OBJS:.cmo=.cmx) | |
80 | ||
81 | CTLOBJS = $(CTLSOURCES:.ml=.cmo) | |
82 | CTLOPTOBJS = $(CTLOBJS:.cmo=.cmx) | |
83 | ||
abad11c5 | 84 | ifneq ($(FEATURE_OCAMLBUILD),yes) |
34e49164 C |
85 | all: $(LIB) |
86 | ||
d6ce1786 C |
87 | all.opt: |
88 | @$(MAKE) $(OPTLIB) BUILD_OPT=yes | |
34e49164 C |
89 | |
90 | ctl: $(CTLEXEC) | |
91 | ||
92 | ||
93 | $(LIB): $(OBJS) | |
feec80c3 | 94 | $(OCAMLC_CMD) -a -o $(LIB) $(OBJS) |
34e49164 C |
95 | |
96 | clean:: | |
abad11c5 | 97 | rm -f $(TARGET).cma $(TARGET).a $(TARGET).o $(TARGET).cmxa |
34e49164 C |
98 | |
99 | ||
b1b2de81 | 100 | $(OPTLIB): $(OPTOBJS) |
feec80c3 | 101 | $(OCAMLOPT_CMD) -a -o $(OPTLIB) $(OPTOBJS) |
34e49164 C |
102 | |
103 | ||
104 | $(EXEC): $(OBJS) main.cmo $(LIBS) | |
feec80c3 | 105 | $(OCAMLC_CMD) -o $(EXEC) $(SYSLIBS) $(LIBS) $(OBJS) main.cmo |
34e49164 C |
106 | |
107 | $(CTLEXEC): $(CTLOBJS) $(LIBS) | |
feec80c3 | 108 | $(OCAMLC_CMD) -o $(CTLEXEC) $(SYSLIBS) $(LIBS) $(CTLOBJS) |
abad11c5 C |
109 | else |
110 | all: | |
111 | cd .. && $(OCAMLBUILD) python/python.cma | |
112 | all.opt: | |
113 | cd .. && $(OCAMLBUILD) python/python.cmxa | |
114 | clean:: | |
115 | cd .. && $(OCAMLBUILD) -clean | |
116 | endif | |
34e49164 C |
117 | |
118 | clean:: | |
b1b2de81 | 119 | rm -f $(OPTLIB) $(LIB:.cma=.a) |
c491d8ee C |
120 | rm -f $(TARGET) |
121 | rm -f $(TARGET).byte | |
34e49164 | 122 | rm -f $(CTLTARGET) |
feec80c3 | 123 | rm -f .depend |
abad11c5 | 124 | rm -f coccipython.cmxa coccipython.a |
34e49164 | 125 | |
c491d8ee C |
126 | distclean:: |
127 | $(MAKE) -C coccilib $@ | |
c491d8ee | 128 | rm -f pycocci.ml |
abad11c5 | 129 | rm -f *.cm[ioxa] *.o *.annot |
34e49164 C |
130 | |
131 | ############################################################################## | |
132 | # Generic ocaml rules | |
133 | ############################################################################## | |
134 | ||
135 | .SUFFIXES: | |
136 | .SUFFIXES: .ml .mli .cmo .cmi .cmx | |
137 | ||
138 | .ml.cmo: | |
feec80c3 | 139 | $(OCAMLC_CMD) -c $< |
34e49164 C |
140 | |
141 | .mli.cmi: | |
feec80c3 | 142 | $(OCAMLC_CMD) -c $< |
34e49164 C |
143 | |
144 | .ml.cmx: | |
feec80c3 | 145 | $(OCAMLOPT_CMD) -c $< |
34e49164 C |
146 | |
147 | ||
148 | # clean rule for others files | |
149 | clean:: | |
150 | rm -f *.cm[iox] *.o *.annot | |
b1b2de81 C |
151 | rm -f *~ .*~ #*# |
152 | ||
feec80c3 C |
153 | .PHONEY: depend |
154 | .depend depend: | |
155 | $(OCAMLDEP_CMD) *.mli *.ml > .depend | |
34e49164 | 156 | |
feec80c3 C |
157 | ifneq ($(MAKECMDGOALS),clean) |
158 | ifneq ($(MAKECMDGOALS),distclean) | |
abad11c5 | 159 | ifneq ($(FEATURE_OCAMLBUILD),yes) |
34e49164 | 160 | -include .depend |
feec80c3 C |
161 | endif |
162 | endif | |
abad11c5 | 163 | endif |
d6ce1786 C |
164 | |
165 | include ../Makefile.common |