Commit | Line | Data |
---|---|---|
f537ebc4 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 | ||
951c7801 | 23 | |
34e49164 C |
24 | ############################################################################# |
25 | # Configuration section | |
26 | ############################################################################# | |
27 | ||
97111a47 | 28 | -include Makefile.libs |
34e49164 | 29 | -include Makefile.config |
c3e37e97 | 30 | -include /etc/lsb-release |
34e49164 | 31 | |
b1b2de81 | 32 | VERSION=$(shell cat globals/config.ml.in |grep version |perl -p -e 's/.*"(.*)".*/$$1/;') |
951c7801 | 33 | CCVERSION=$(shell cat scripts/coccicheck/README |grep "Coccicheck version" |perl -p -e 's/.*version (.*)[ ]*/$$1/;') |
c3e37e97 C |
34 | PKGVERSION=$(shell dpkg-parsechangelog -ldebian/changelog.$(DISTRIB_CODENAME) 2> /dev/null \ |
35 | | sed -n 's/^Version: \(.*\)/\1/p' ) | |
34e49164 C |
36 | |
37 | ############################################################################## | |
38 | # Variables | |
39 | ############################################################################## | |
40 | TARGET=spatch | |
c3e37e97 | 41 | PRJNAME=coccinelle |
34e49164 | 42 | |
993936c0 C |
43 | LEXER_SOURCES = |
44 | SRC=flag_cocci.ml cocci.ml testing.ml test.ml $(LEXER_SOURCES:.mll=.ml) main.ml | |
34e49164 | 45 | |
34e49164 | 46 | ifeq ($(FEATURE_PYTHON),1) |
90aeb998 | 47 | PYCMA=pycaml.cma |
b1b2de81 | 48 | # the following is essential for Coccinelle to compile under gentoo (weird) |
90aeb998 | 49 | #OPTLIBFLAGS=-cclib dllpycaml_stubs.so |
34e49164 C |
50 | else |
51 | PYCMA= | |
90aeb998 | 52 | endif |
34e49164 | 53 | OPTLIBFLAGS= |
90aeb998 C |
54 | |
55 | ifeq ("$(SEXPDIR)","ocamlsexp") | |
97111a47 | 56 | SEXPLIB=ocamlsexp/sexplib.cmo |
90aeb998 C |
57 | OPTSEXPLIB=sexplib.cmx |
58 | else | |
59 | SEXPLIB=sexplib.cma | |
60 | OPTSEXPLIB=sexplib.cmxa | |
34e49164 C |
61 | endif |
62 | ||
88e71198 C |
63 | ifeq ("$(DYNLINK)","no") |
64 | DYNLINK= | |
65 | else | |
66 | DYNLINK=dynlink.cma | |
67 | endif | |
68 | ||
993936c0 C |
69 | ifdef PCREDIR |
70 | PCRELIB=pcre.cma | |
71 | else | |
72 | PCRELIB= | |
73 | PCREDIR= | |
74 | endif | |
75 | ||
b1b2de81 | 76 | SEXPSYSCMA=bigarray.cma nums.cma |
34e49164 | 77 | |
97111a47 | 78 | SYSLIBS=str.cma unix.cma $(SEXPSYSCMA) $(DYNLINK) $(PCRELIB) # threads.cma |
b1b2de81 | 79 | LIBS=commons/commons.cma \ |
90aeb998 | 80 | commons/commons_sexp.cma \ |
b1b2de81 | 81 | globals/globals.cma \ |
34e49164 C |
82 | ctl/ctl.cma \ |
83 | parsing_cocci/cocci_parser.cma parsing_c/parsing_c.cma \ | |
951c7801 | 84 | engine/cocciengine.cma popl09/popl.cma \ |
174d1640 | 85 | extra/extra.cma python/coccipython.cma ocaml/cocciocaml.cma |
90aeb998 C |
86 | |
87 | # Should we use the local version of pycaml | |
b23ff9c7 | 88 | ifeq ($(FEATURE_PYTHON),1) |
90aeb998 C |
89 | ifeq ("$(PYCAMLDIR)","pycaml") |
90 | LOCALPYCAML=pycaml | |
91 | else | |
92 | LOCALPYCAML= | |
93 | endif | |
b23ff9c7 | 94 | endif |
90aeb998 C |
95 | |
96 | # Should we use the local version of menhirLib | |
174d1640 C |
97 | ifeq ("$(MENHIRDIR)","menhirlib") |
98 | LOCALMENHIR=menhirlib | |
90aeb998 C |
99 | else |
100 | LOCALMENHIR= | |
101 | endif | |
102 | ||
103 | # Should we use the local version of ocamlsexp | |
104 | ifeq ("$(SEXPDIR)","ocamlsexp") | |
105 | LOCALSEXP=ocamlsexp | |
106 | else | |
107 | LOCALSEXP= | |
108 | endif | |
34e49164 | 109 | |
174d1640 | 110 | # used for depend: and a little for rec & rec.opt |
97111a47 | 111 | MAKESUBDIRS=$(LOCALSEXP) commons \ |
90aeb998 | 112 | globals $(LOCALMENHIR) ctl parsing_cocci parsing_c \ |
97111a47 C |
113 | engine popl09 extra python ocaml \ |
114 | $(MAKELIBS) | |
174d1640 C |
115 | |
116 | # used for clean: | |
117 | # It is like MAKESUBDIRS but also | |
118 | # force cleaning of local library copies | |
119 | CLEANSUBDIRS=pycaml ocamlsexp commons \ | |
120 | globals menhirlib ctl parsing_cocci parsing_c \ | |
97111a47 C |
121 | engine popl09 extra python ocaml \ |
122 | $(CLEANLIBS) | |
90aeb998 C |
123 | |
124 | INCLUDEDIRSDEP=commons commons/ocamlextra $(LOCALSEXP) \ | |
125 | globals $(LOCALMENHIR) $(LOCALPYCAML) ctl \ | |
97111a47 C |
126 | parsing_cocci parsing_c engine popl09 extra python ocaml \ |
127 | $(DEPLIBS) | |
34e49164 | 128 | |
97111a47 C |
129 | INCLUDEDIRS=$(INCLUDEDIRSDEP) $(SEXPDIR) $(MENHIRDIR) $(PYCAMLDIR) $(PCREDIR) $(INCLIBS) |
130 | ||
131 | EXTRALINKS= | |
132 | LINKFLAGS=$(EXTRALINKS:%=-cclib -l%) | |
90aeb998 | 133 | |
34e49164 C |
134 | ############################################################################## |
135 | # Generic variables | |
136 | ############################################################################## | |
137 | ||
138 | INCLUDES=$(INCLUDEDIRS:%=-I %) | |
139 | ||
140 | OBJS= $(SRC:.ml=.cmo) | |
141 | OPTOBJS= $(SRC:.ml=.cmx) | |
142 | ||
143 | EXEC=$(TARGET) | |
144 | ||
145 | ############################################################################## | |
146 | # Generic ocaml variables | |
147 | ############################################################################## | |
148 | ||
ae4735db | 149 | OCAMLCFLAGS= |
34e49164 C |
150 | |
151 | # for profiling add -p -inline 0 | |
152 | # but 'make forprofiling' below does that for you. | |
153 | # This flag is also used in subdirectories so don't change its name here. | |
708f4980 | 154 | # To enable backtrace support for native code, you need to put -g in OPTFLAGS |
c491d8ee C |
155 | # to also link with -g. |
156 | OPTFLAGS= -g | |
34e49164 | 157 | |
97111a47 C |
158 | OCAMLC=ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(LINKFLAGS) $(INCLUDES) |
159 | OCAMLOPT=ocamlopt$(OPTBIN) $(OPTFLAGS) $(LINKFLAGS) $(INCLUDES) | |
34e49164 C |
160 | OCAMLLEX=ocamllex #-ml # -ml for debugging lexer, but slightly slower |
161 | OCAMLYACC=ocamlyacc -v | |
90aeb998 | 162 | OCAMLDEP=ocamldep $(INCLUDEDIRSDEP:%=-I %) |
34e49164 C |
163 | OCAMLMKTOP=ocamlmktop -g -custom $(INCLUDES) |
164 | ||
165 | # can also be set via 'make static' | |
993936c0 | 166 | CFLAGS=-pie -fPIE -fpic -fPIC -static |
6756e19d C |
167 | STATICCFLAGS=$(CFLAGS:%=-ccopt %) |
168 | STATIC= # $(STATICCFLAGS) | |
34e49164 C |
169 | |
170 | # can also be unset via 'make purebytecode' | |
171 | BYTECODE_STATIC=-custom | |
172 | ||
173 | ############################################################################## | |
174 | # Top rules | |
175 | ############################################################################## | |
b1b2de81 C |
176 | .PHONY:: all all.opt byte opt top clean distclean configure |
177 | .PHONY:: $(MAKESUBDIRS) $(MAKESUBDIRS:%=%.opt) subdirs subdirs.opt | |
178 | ||
708f4980 | 179 | all: Makefile.config byte preinstall |
b1b2de81 | 180 | |
7fe62b65 | 181 | opt all.opt: opt-compil preinstall |
faf9a90c | 182 | |
708f4980 | 183 | world: preinstall |
b1b2de81 | 184 | $(MAKE) byte |
708f4980 | 185 | $(MAKE) opt-compil |
b1b2de81 C |
186 | |
187 | byte: .depend | |
faf9a90c C |
188 | $(MAKE) subdirs |
189 | $(MAKE) $(EXEC) | |
190 | ||
b1b2de81 | 191 | opt-compil: .depend |
faf9a90c C |
192 | $(MAKE) subdirs.opt |
193 | $(MAKE) $(EXEC).opt | |
194 | ||
485bce71 | 195 | top: $(EXEC).top |
34e49164 | 196 | |
0708f913 | 197 | subdirs: |
b1b2de81 | 198 | +for D in $(MAKESUBDIRS); do $(MAKE) $$D || exit 1 ; done |
90aeb998 | 199 | $(MAKE) -C commons sexp OCAMLCFLAGS="$(OCAMLCFLAGS)" |
0708f913 C |
200 | |
201 | subdirs.opt: | |
b1b2de81 | 202 | +for D in $(MAKESUBDIRS); do $(MAKE) $$D.opt || exit 1 ; done |
aba5c457 | 203 | $(MAKE) -C commons sexp.opt OPTFLAGS="$(OPTFLAGS)" |
faf9a90c C |
204 | |
205 | $(MAKESUBDIRS): | |
206 | $(MAKE) -C $@ OCAMLCFLAGS="$(OCAMLCFLAGS)" all | |
207 | ||
208 | $(MAKESUBDIRS:%=%.opt): | |
aba5c457 | 209 | $(MAKE) -C $(@:%.opt=%) OPTFLAGS="$(OPTFLAGS)" all.opt |
faf9a90c | 210 | |
b1b2de81 | 211 | #dependencies: |
0708f913 C |
212 | # commons: |
213 | # globals: | |
214 | # menhirlib: | |
215 | # parsing_cocci: commons globals menhirlib | |
216 | # parsing_c:parsing_cocci | |
217 | # ctl:globals commons | |
218 | # engine: parsing_cocci parsing_c ctl | |
951c7801 | 219 | # popl09:engine |
0708f913 C |
220 | # extra: parsing_cocci parsing_c ctl |
221 | # pycaml: | |
222 | # python:pycaml parsing_cocci parsing_c | |
faf9a90c | 223 | |
34e49164 | 224 | clean:: |
174d1640 | 225 | set -e; for i in $(CLEANSUBDIRS); do $(MAKE) -C $$i $@; done |
c3e37e97 | 226 | $(MAKE) -C demos/spp $@ |
34e49164 | 227 | |
0708f913 C |
228 | $(LIBS): $(MAKESUBDIRS) |
229 | $(LIBS:.cma=.cmxa): $(MAKESUBDIRS:%=%.opt) | |
97111a47 C |
230 | $(LNKLIBS) : $(MAKESUBDIRS) |
231 | $(LNKOPTLIBS) : $(MAKESUBDIRS:%=%.opt) | |
faf9a90c | 232 | |
97111a47 C |
233 | $(OBJS):$(LIBS) $(LNKLIBS) |
234 | $(OPTOBJS):$(LIBS:.cma=.cmxa) $(LNKOPTLIBS) | |
faf9a90c | 235 | |
34e49164 | 236 | $(EXEC): $(LIBS) $(OBJS) |
97111a47 | 237 | $(OCAMLC) $(BYTECODE_STATIC) -o $@ $(SYSLIBS) $(SEXPLIB) $(LNKLIBS) $^ |
34e49164 | 238 | |
faf9a90c | 239 | $(EXEC).opt: $(LIBS:.cma=.cmxa) $(OPTOBJS) |
97111a47 | 240 | $(OCAMLOPT) $(STATIC) -o $@ $(SYSLIBS:.cma=.cmxa) $(OPTSEXPLIB) $(OPTLIBFLAGS) $(FLAGSLIB) $(OPTLNKLIBS) $^ |
34e49164 | 241 | |
97111a47 C |
242 | $(EXEC).top: $(LIBS) $(OBJS) $(LNKLIBS) |
243 | $(OCAMLMKTOP) -custom -o $@ $(SYSLIBS) $(SEXPLIB) $(LNKLIBS) $^ | |
34e49164 C |
244 | |
245 | clean:: | |
246 | rm -f $(TARGET) $(TARGET).opt $(TARGET).top | |
34e49164 | 247 | |
b1b2de81 C |
248 | .PHONY:: tools configure |
249 | ||
250 | configure: | |
251 | ./configure | |
34e49164 | 252 | |
7f004419 | 253 | Makefile.config: |
708f4980 C |
254 | @echo "Makefile.config is missing. Have you run ./configure?" |
255 | @exit 1 | |
256 | ||
97111a47 | 257 | tools: $(LIBS) $(LNKLIBS) |
34e49164 | 258 | $(MAKE) -C tools |
b1b2de81 | 259 | |
c491d8ee C |
260 | distclean:: |
261 | if [ -d tools ] ; then $(MAKE) -C tools distclean ; fi | |
34e49164 | 262 | |
34e49164 C |
263 | static: |
264 | rm -f spatch.opt spatch | |
6756e19d | 265 | $(MAKE) STATIC="$(STATICCFLAGS)" spatch.opt |
34e49164 C |
266 | cp spatch.opt spatch |
267 | ||
268 | purebytecode: | |
269 | rm -f spatch.opt spatch | |
270 | $(MAKE) BYTECODE_STATIC="" spatch | |
fc1ad971 | 271 | perl -p -i -e 's/^#!.*/#!\/usr\/bin\/ocamlrun/' spatch |
34e49164 C |
272 | |
273 | ||
b1b2de81 C |
274 | ############################################################################## |
275 | # Build documentation | |
276 | ############################################################################## | |
277 | .PHONY:: docs | |
278 | ||
279 | docs: | |
f3c4ece6 C |
280 | $(MAKE) -C docs |
281 | if [ -x "$(TARGET)" -o -x "$(TARGET).opt" ]; \ | |
282 | then $(MAKE) -C ocaml doc; fi | |
b1b2de81 C |
283 | |
284 | clean:: | |
f3c4ece6 C |
285 | $(MAKE) -C docs clean |
286 | $(MAKE) -C ocaml cleandoc | |
b1b2de81 C |
287 | |
288 | distclean:: | |
f3c4ece6 | 289 | $(MAKE) -C docs distclean |
b1b2de81 C |
290 | |
291 | ############################################################################## | |
292 | # Pre-Install (customization of spatch frontend script) | |
293 | ############################################################################## | |
b1b2de81 | 294 | |
90aeb998 C |
295 | preinstall: docs/spatch.1 scripts/spatch scripts/spatch.opt scripts/spatch.byte |
296 | ||
297 | docs/spatch.1: Makefile.config | |
298 | $(MAKE) -C docs spatch.1 | |
b1b2de81 C |
299 | |
300 | # user will use spatch to run spatch.opt (native) | |
5636bb2c | 301 | scripts/spatch: Makefile.config |
b1b2de81 C |
302 | cp scripts/spatch.sh scripts/spatch.tmp2 |
303 | sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.tmp2 > scripts/spatch.tmp | |
304 | sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.tmp > scripts/spatch | |
305 | rm -f scripts/spatch.tmp2 scripts/spatch.tmp | |
306 | ||
307 | # user will use spatch to run spatch (bytecode) | |
5636bb2c | 308 | scripts/spatch.byte: Makefile.config |
708f4980 C |
309 | cp scripts/spatch.sh scripts/spatch.byte.tmp3 |
310 | sed "s|\.opt||" scripts/spatch.byte.tmp3 > scripts/spatch.byte.tmp2 | |
311 | sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.byte.tmp2 \ | |
312 | > scripts/spatch.byte.tmp | |
313 | sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.byte.tmp \ | |
314 | > scripts/spatch.byte | |
315 | rm -f scripts/spatch.byte.tmp3 \ | |
316 | scripts/spatch.byte.tmp2 \ | |
317 | scripts/spatch.byte.tmp | |
b1b2de81 C |
318 | |
319 | # user will use spatch.opt to run spatch.opt (native) | |
5636bb2c | 320 | scripts/spatch.opt: Makefile.config |
b1b2de81 | 321 | cp scripts/spatch.sh scripts/spatch.opt.tmp2 |
708f4980 C |
322 | sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.opt.tmp2 \ |
323 | > scripts/spatch.opt.tmp | |
324 | sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.opt.tmp \ | |
325 | > scripts/spatch.opt | |
b1b2de81 C |
326 | rm -f scripts/spatch.opt.tmp scripts/spatch.opt.tmp2 |
327 | ||
328 | clean:: | |
329 | rm -f scripts/spatch scripts/spatch.byte scripts/spatch.opt | |
330 | ||
34e49164 C |
331 | ############################################################################## |
332 | # Install | |
333 | ############################################################################## | |
334 | ||
335 | # don't remove DESTDIR, it can be set by package build system like ebuild | |
8ba84ae2 | 336 | # for staged installation. |
0708f913 | 337 | install-common: |
34e49164 C |
338 | mkdir -p $(DESTDIR)$(BINDIR) |
339 | mkdir -p $(DESTDIR)$(LIBDIR) | |
174d1640 | 340 | mkdir -p $(DESTDIR)$(SHAREDIR)/ocaml |
413ffc02 | 341 | mkdir -p $(DESTDIR)$(SHAREDIR)/commons |
ca417fcf | 342 | mkdir -p $(DESTDIR)$(SHAREDIR)/globals |
413ffc02 | 343 | mkdir -p $(DESTDIR)$(SHAREDIR)/parsing_c |
8ba84ae2 C |
344 | $(INSTALL_DATA) standard.h $(DESTDIR)$(SHAREDIR) |
345 | $(INSTALL_DATA) standard.iso $(DESTDIR)$(SHAREDIR) | |
174d1640 | 346 | $(INSTALL_DATA) ocaml/coccilib.cmi $(DESTDIR)$(SHAREDIR)/ocaml/ |
413ffc02 C |
347 | $(INSTALL_DATA) parsing_c/*.cmi $(DESTDIR)$(SHAREDIR)/parsing_c/ |
348 | $(INSTALL_DATA) commons/*.cmi $(DESTDIR)$(SHAREDIR)/commons/ | |
ca417fcf | 349 | $(INSTALL_DATA) globals/iteration.cmi $(DESTDIR)$(SHAREDIR)/globals/ |
f3c4ece6 C |
350 | @if [ $(FEATURE_PYTHON) -eq 1 ]; then $(MAKE) install-python; fi |
351 | ||
352 | install-man: | |
353 | mkdir -p $(DESTDIR)$(MANDIR)/man1 | |
354 | mkdir -p $(DESTDIR)$(MANDIR)/man3 | |
8ba84ae2 | 355 | $(INSTALL_DATA) docs/spatch.1 $(DESTDIR)$(MANDIR)/man1/ |
65038c61 | 356 | $(INSTALL_DATA) docs/Coccilib.3cocci $(DESTDIR)$(MANDIR)/man3/ |
174d1640 C |
357 | |
358 | install-bash: | |
359 | mkdir -p $(DESTDIR)$(BASH_COMPLETION_DIR) | |
360 | $(INSTALL_DATA) scripts/spatch.bash_completion \ | |
361 | $(DESTDIR)$(BASH_COMPLETION_DIR)/spatch | |
0708f913 | 362 | |
c491d8ee C |
363 | install-tools: |
364 | mkdir -p $(DESTDIR)$(BINDIR) | |
365 | $(INSTALL_PROGRAM) tools/splitpatch \ | |
366 | $(DESTDIR)$(BINDIR)/splitpatch | |
367 | $(INSTALL_PROGRAM) tools/cocci-send-email.perl \ | |
368 | $(DESTDIR)$(BINDIR)/cocci-send-email.perl | |
369 | ||
8ba84ae2 C |
370 | install-python: |
371 | mkdir -p $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui | |
372 | $(INSTALL_DATA) python/coccilib/*.py \ | |
373 | $(DESTDIR)$(SHAREDIR)/python/coccilib | |
374 | $(INSTALL_DATA) python/coccilib/coccigui/*.py \ | |
375 | $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui | |
b1b2de81 C |
376 | $(INSTALL_DATA) python/coccilib/coccigui/pygui.glade \ |
377 | $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui | |
378 | $(INSTALL_DATA) python/coccilib/coccigui/pygui.gladep \ | |
379 | $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui | |
90aeb998 C |
380 | if [ -f pycaml/dllpycaml_stubs.so ]; then \ |
381 | $(INSTALL_LIB) pycaml/dllpycaml_stubs.so $(DESTDIR)$(LIBDIR) ; fi | |
8ba84ae2 | 382 | |
f3c4ece6 | 383 | install: install-man install-common |
b1b2de81 C |
384 | @if test -x spatch -a ! -x spatch.opt ; then \ |
385 | $(MAKE) install-byte;fi | |
386 | @if test ! -x spatch -a -x spatch.opt ; then \ | |
387 | $(MAKE) install-def; $(MAKE) install-opt;fi | |
388 | @if test -x spatch -a -x spatch.opt ; then \ | |
389 | $(MAKE) install-byte; $(MAKE) install-opt;fi | |
390 | @if test ! -x spatch -a ! -x spatch.opt ; then \ | |
391 | echo "\n\n\t==> Run 'make', 'make opt', or both first. <==\n\n";fi | |
708f4980 C |
392 | @echo "" |
393 | @echo "\tYou can also install spatch by copying the program spatch" | |
394 | @echo "\t(available in this directory) anywhere you want and" | |
395 | @echo "\tgive it the right options to find its configuration files." | |
396 | @echo "" | |
b1b2de81 | 397 | |
0708f913 | 398 | # user will use spatch to run spatch.opt (native) |
708f4980 | 399 | install-def: |
8ba84ae2 | 400 | $(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(SHAREDIR) |
b1b2de81 | 401 | $(INSTALL_PROGRAM) scripts/spatch $(DESTDIR)$(BINDIR)/spatch |
0708f913 C |
402 | |
403 | # user will use spatch to run spatch (bytecode) | |
708f4980 | 404 | install-byte: |
8ba84ae2 | 405 | $(INSTALL_PROGRAM) spatch $(DESTDIR)$(SHAREDIR) |
b1b2de81 | 406 | $(INSTALL_PROGRAM) scripts/spatch.byte $(DESTDIR)$(BINDIR)/spatch |
0708f913 C |
407 | |
408 | # user will use spatch.opt to run spatch.opt (native) | |
708f4980 | 409 | install-opt: |
8ba84ae2 | 410 | $(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(SHAREDIR) |
b1b2de81 | 411 | $(INSTALL_PROGRAM) scripts/spatch.opt $(DESTDIR)$(BINDIR)/spatch.opt |
34e49164 C |
412 | |
413 | uninstall: | |
414 | rm -f $(DESTDIR)$(BINDIR)/spatch | |
8ba84ae2 | 415 | rm -f $(DESTDIR)$(BINDIR)/spatch.opt |
34e49164 | 416 | rm -f $(DESTDIR)$(LIBDIR)/dllpycaml_stubs.so |
90aeb998 C |
417 | rm -f $(DESTDIR)$(SHAREDIR)/spatch |
418 | rm -f $(DESTDIR)$(SHAREDIR)/spatch.opt | |
34e49164 C |
419 | rm -f $(DESTDIR)$(SHAREDIR)/standard.h |
420 | rm -f $(DESTDIR)$(SHAREDIR)/standard.iso | |
174d1640 | 421 | rm -f $(DESTDIR)$(SHAREDIR)/ocaml/coccilib.cmi |
413ffc02 | 422 | rm -f $(DESTDIR)$(SHAREDIR)/parsing_c/*.cmi |
ca417fcf C |
423 | rm -f $(DESTDIR)$(SHAREDIR)/commons/*.cmi |
424 | rm -f $(DESTDIR)$(SHAREDIR)/globals/*.cmi | |
90aeb998 C |
425 | rm -f $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui/* |
426 | rm -f $(DESTDIR)$(SHAREDIR)/python/coccilib/*.py | |
427 | rmdir --ignore-fail-on-non-empty -p \ | |
428 | $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui | |
ca417fcf C |
429 | rmdir $(DESTDIR)$(SHAREDIR)/globals |
430 | rmdir $(DESTDIR)$(SHAREDIR)/commons | |
431 | rmdir $(DESTDIR)$(SHAREDIR)/parsing_c | |
432 | rmdir $(DESTDIR)$(SHAREDIR)/ocaml | |
433 | rmdir $(DESTDIR)$(SHAREDIR) | |
faf9a90c | 434 | rm -f $(DESTDIR)$(MANDIR)/man1/spatch.1 |
65038c61 | 435 | rm -f $(DESTDIR)$(MANDIR)/man3/Coccilib.3cocci |
34e49164 | 436 | |
aba5c457 C |
437 | uninstall-bash: |
438 | rm -f $(DESTDIR)$(BASH_COMPLETION_DIR)/spatch | |
439 | rmdir --ignore-fail-on-non-empty -p \ | |
440 | $(DESTDIR)$(BASH_COMPLETION_DIR) | |
441 | ||
c491d8ee C |
442 | uninstall-tools: |
443 | rm -f $(DESTDIR)$(BINDIR)/splitpatch | |
444 | rm -f $(DESTDIR)$(BINDIR)/cocci-send-email.perl | |
445 | ||
34e49164 | 446 | version: |
951c7801 | 447 | @echo "spatch $(VERSION)" |
c3e37e97 | 448 | @echo "spatch $(PKGVERSION) ($(DISTRIB_ID))" |
951c7801 | 449 | @echo "coccicheck $(CCVERSION)" |
34e49164 C |
450 | |
451 | ||
452 | ############################################################################## | |
5636bb2c | 453 | # Deb package (for Ubuntu) and release rules |
34e49164 C |
454 | ############################################################################## |
455 | ||
5636bb2c | 456 | include Makefile.release |
c3e37e97 | 457 | |
34e49164 C |
458 | ############################################################################## |
459 | # Developer rules | |
460 | ############################################################################## | |
461 | ||
7f004419 C |
462 | -include Makefile.dev |
463 | ||
34e49164 C |
464 | test: $(TARGET) |
465 | ./$(TARGET) -testall | |
466 | ||
467 | testparsing: | |
468 | ./$(TARGET) -D standard.h -parse_c -dir tests/ | |
469 | ||
470 | ||
471 | ||
faf9a90c C |
472 | # -inline 0 to see all the functions in the profile. |
473 | # Can also use the profile framework in commons/ and run your program | |
34e49164 C |
474 | # with -profile. |
475 | forprofiling: | |
476 | $(MAKE) OPTFLAGS="-p -inline 0 " opt | |
477 | ||
478 | clean:: | |
faf9a90c | 479 | rm -f gmon.out |
34e49164 C |
480 | |
481 | tags: | |
482 | otags -no-mli-tags -r . | |
483 | ||
484 | dependencygraph: | |
951c7801 | 485 | find -name "*.ml" |grep -v "scripts" | xargs ocamldep -I commons -I globals -I ctl -I parsing_cocci -I parsing_c -I engine -I popl09 -I extra > /tmp/dependfull.depend |
485bce71 | 486 | ocamldot -lr /tmp/dependfull.depend > /tmp/dependfull.dot |
34e49164 | 487 | dot -Tps /tmp/dependfull.dot > /tmp/dependfull.ps |
485bce71 | 488 | ps2pdf /tmp/dependfull.ps /tmp/dependfull.pdf |
34e49164 C |
489 | |
490 | ############################################################################## | |
491 | # Misc rules | |
492 | ############################################################################## | |
493 | ||
faf9a90c | 494 | # each member of the project can have its own test.ml. this file is |
34e49164 | 495 | # not under CVS. |
faf9a90c | 496 | test.ml: |
34e49164 C |
497 | echo "let foo_ctl () = failwith \"there is no foo_ctl formula\"" \ |
498 | > test.ml | |
499 | ||
500 | beforedepend:: test.ml | |
501 | ||
502 | ||
503 | #INC=$(dir $(shell which ocaml)) | |
504 | #INCX=$(INC:/=) | |
505 | #INCY=$(dir $(INCX)) | |
506 | #INCZ=$(INCY:/=)/lib/ocaml | |
507 | # | |
508 | #prim.o: prim.c | |
509 | # gcc -c -o prim.o -I $(INCZ) prim.c | |
510 | ||
511 | ||
512 | ############################################################################## | |
513 | # Generic ocaml rules | |
514 | ############################################################################## | |
515 | ||
516 | .SUFFIXES: .ml .mli .cmo .cmi .cmx | |
517 | ||
518 | .ml.cmo: | |
519 | $(OCAMLC) -c $< | |
520 | .mli.cmi: | |
521 | $(OCAMLC) -c $< | |
522 | .ml.cmx: | |
523 | $(OCAMLOPT) -c $< | |
524 | ||
faf9a90c | 525 | .ml.mldepend: |
34e49164 C |
526 | $(OCAMLC) -i $< |
527 | ||
993936c0 C |
528 | $(LEXER_SOURCES:.mll=.ml) : $(LEXER_SOURCES) |
529 | $(OCAMLLEX) $(LEXER_SOURCES) | |
530 | ||
34e49164 C |
531 | clean:: |
532 | rm -f *.cm[iox] *.o *.annot | |
34e49164 C |
533 | rm -f *~ .*~ *.exe #*# |
534 | ||
b1b2de81 C |
535 | distclean:: clean |
536 | set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i $@; done | |
537 | rm -f .depend | |
538 | rm -f Makefile.config | |
b23ff9c7 | 539 | rm -f globals/config.ml test.ml |
b1b2de81 C |
540 | rm -f TAGS |
541 | rm -f tests/SCORE_actual.sexp | |
542 | rm -f tests/SCORE_best_of_both.sexp | |
543 | find -name ".#*1.*" | xargs rm -f | |
544 | ||
34e49164 C |
545 | beforedepend:: |
546 | ||
547 | depend:: beforedepend | |
548 | $(OCAMLDEP) *.mli *.ml > .depend | |
b1b2de81 C |
549 | set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i $@; done |
550 | ||
551 | .depend:: | |
552 | @if [ ! -f .depend ] ; then $(MAKE) depend ; fi | |
34e49164 C |
553 | |
554 | -include .depend |