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