readme.txt 1.58 KB
Newer Older
Yoann Padioleau's avatar
Yoann Padioleau committed
1
2
3
                            Coccinelle 


Yoann Padioleau's avatar
Yoann Padioleau committed
4
5
6
7
8
Coccinelle allows programmers to easily write some complex
style-preserving source-to-source transformations on C source code,
like for instance to perform some refactorings.

To install Coccinelle from its source, see the instructions in install.txt.
Arie Middelkoop's avatar
Arie Middelkoop committed
9
10
11
12
13
14
Once you have installed coccinelle, there is a script 'spatch' in /usr/bin
or /usr/local/bin that invokes the Coccinelle program.

If you want to run Coccinelle without installing it, you can run the
Coccinelle program directly from the download/build directory. You may then
have to setup a few environment variables so that the Coccinelle program
Yoann Padioleau's avatar
Yoann Padioleau committed
15
knows where to find its configuration files.
Yoann Padioleau's avatar
Yoann Padioleau committed
16
17
For bash do:

Yoann Padioleau's avatar
Yoann Padioleau committed
18
  $ source env.sh
Yoann Padioleau's avatar
Yoann Padioleau committed
19
20
21

For tcsh do:

Yoann Padioleau's avatar
Yoann Padioleau committed
22
  $ source env.csh 
Yoann Padioleau's avatar
Yoann Padioleau committed
23

Arie Middelkoop's avatar
Arie Middelkoop committed
24
25

You can test coccinelle with:
Yoann Padioleau's avatar
Yoann Padioleau committed
26

27
  $ spatch -sp_file demos/simple.cocci demos/simple.c -o /tmp/new_simple.c
Yoann Padioleau's avatar
Yoann Padioleau committed
28

Arie Middelkoop's avatar
Arie Middelkoop committed
29
If you haven't installed coccinelle, run then ./spatch or ./spatch.opt 
Yoann Padioleau's avatar
Yoann Padioleau committed
30
31
32



Yoann Padioleau's avatar
Yoann Padioleau committed
33
34
35
36
If you downloaded the bytecode version of spatch you may first 
have to install OCaml (which contains the 'ocamlrun' bytecode interpreter,
the equivalent of 'java', the Java virtual machine, but for OCaml) and then do:

37
  $ ocamlrun spatch -sp_file demos/simple.cocci demos/simple.c -o /tmp/new_simple.c
Yoann Padioleau's avatar
Yoann Padioleau committed
38
39
40
41
42
43
44


For more information on Coccinelle, type 'make docs' and have a look at the 
files in the docs/ directory. You may need to install the texlive-fonts-extra
packages from your distribution to compile some of the LaTeX documentation
files.

Nicolas Palix's avatar
Nicolas Palix committed
45
46
47
48
49
 ** Runtime dependencies under Debian/Ubuntu**

 - For the OCaml scripting feature in SmPL
	ocaml-native-compilers
     or ocaml-nox