3 # Author: Yoann Padioleau
5 ######################################################################
7 ######################################################################
9 # Yes I know about autoconf ... and autoconf sux.
11 # assume standard: diff
12 # assume standard: perl
14 #TODO check python 2.5 ?
16 #old: --with-menhir=/path/to/menhirLib or `ocamlfind query menhirLib`
21 "spatch -sp_file demos/simple.cocci demos/simple.c";
23 ######################################################################
25 ######################################################################
27 my $prefix="/usr/local";
32 local $_ = join ' ', @ARGV;
35 /-h/ || /--help/ and die "usage: $0 [--prefix=path] [--without-python] [--with-trac] [--no-opt]\n\n\t--no-opt\tDo not use the optimimized version of OCaml\n\t--opt\tUse the optimimized version of OCaml\n\n";
36 /--prefix=([^ ]*)/ and $prefix = $1;
37 /--without-python/ and $python = 0;
38 /--without-trac/ and $trac = 0;
39 /--with-trac/ and $trac = 1;
40 /--no-opt/ and $opt = "";
41 /--opt/ and $opt = ".opt";
43 #if($ARGV[0] =~ "--prefix=(.*)") {
46 #if($ARGV[1] =~ "--without-python") {
50 my $src="$prefix/share/$project";
52 ######################################################################
54 ######################################################################
57 ######################################################################
59 ######################################################################
60 #BEGIN { die "need Perl 5 or greater" if $] < 5 ; }
63 sub pr2
{ print STDERR
"@_\n" }
68 while(<TMP
>) { push @list, "$_"; }
72 sub mapf
{ my ($f, $xs) = @_; [ map { &$f($_) } @
{$xs} ] }
73 sub plural
{ my ($e) = @_; if ($e > 1) { "s" } else { "" } }
75 sub check_config
{ my ($command, $expect, $msggood, $msgbad) = @_;
78 my $full = cat
($command);
79 my $res = join(" ", @
{$full});
81 if(notb
($res =~ $expect)) { $error++; pr2
"!!!! $msgbad !!!!"; }
86 ######################################################################
88 ######################################################################
89 pr2
"Checking your configuration.\n";
93 #---------------------------------------------------------------------
94 # Compilers and runtimes
95 #---------------------------------------------------------------------
97 check_config
("echo \"1;;\\n\" | ocaml |",
98 # "Objective(.*) 3.0[9]",
100 "OCaml (the wonderful language) is present.",
101 "The program ocaml is missing or is not a good version. We need at least 3.09",
104 if ($opt eq ".opt") {
105 my $opt_check = `which ocamlc.opt 2> /dev/null`;
106 if($opt_check =~ "/ocamlc.opt\$") {
107 pr2
"ocamlc.opt is present.";
111 pr2
"ocamlc.opt not found";
114 my $opt_check = `which ocamlopt.opt 2> /dev/null`;
115 if($opt_check =~ "/ocamlopt.opt\$") {
116 pr2
"ocamlopt.opt is present.";
120 pr2
"ocamlopt.opt not found";
123 my $opt_check = `which ocamldep.opt 2> /dev/null`;
124 if($opt_check =~ "/ocamldep.opt\$") {
125 pr2
"ocamldep.opt is present.";
129 pr2
"ocamldep.opt not found";
132 my $opt_check = `which ocamllex.opt 2> /dev/null`;
133 if($opt_check =~ "/ocamllex.opt\$") {
134 pr2
"ocamllex.opt is present.";
138 pr2
"ocamllex.opt not found";
142 pr2
"At least one native OCaml tool have not been found.";
143 pr2
"Desactivation of all native OCaml tools for compilation.";
147 #we have cached the result of menhir in the tgz we build.
150 # check_config("menhir --version |",
151 # "menhir, version 20071212",
152 ## "menhir, version 2006.*",
153 # "Menhir (the parser generator) is present.",
154 # "The program menhir is missing or is not a good version.",
158 #---------------------------------------------------------------
160 #---------------------------------------------------------------
164 $error += check_config
(
165 "make -v 2>&1 |grep Make|",
166 "GNU Make [^0-9]*3\.[0-9]+.*", #version 3.79.1, 3.81
167 "make (gnu version) is present.",
168 "The program gnu make is missing or is not a good version.
173 #---------------------------------------------------------------------
174 # More developers tools
175 #---------------------------------------------------------------------
177 #---------------------------------------------------------------------
179 #---------------------------------------------------------------------
181 ######################################################################
182 # Generate config files (platform/portability issues)
183 ######################################################################
186 ######################################################################
187 # Generate globals files (features issues)
188 ######################################################################
190 ######################################################################
192 ######################################################################
197 ----------------------------------------------------------------------
198 !!!! There seems to have problem, we have found $error missing package" .
200 " . (($error > 1) ?
"Some of those packages" : "This package") .
201 " may be installed by picking " . ($error > 1 ?
"them" : "it") .
202 " in $project-dependencies.tgz available
203 on the $project website. !!!!
204 ----------------------------------------------------------------------
208 #pad: before the message was saying (make depend); make all
209 # I found this confusing so I removed it.
213 ----------------------------------------------------------------------
215 All seems fine for $project.
217 To compile $project type:
221 Or alternatively, for the optimized version:
223 If you want both, you could use:
230 Then, to test $project simply type:
237 "To use the python SmPL feature you may have to set some environment variables.
239 export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$prefix/lib
240 export PYTHONPATH=\$PYTHONPATH:$src/python
244 ----------------------------------------------------------------------
250 ######################################################################
251 # Generating the configuration
252 ######################################################################
254 pr2
"$project target prefix: $prefix (you can use --prefix to override it)";
255 pr2
"Generating Makefile.config";
256 open(CONFIG
, ">Makefile.config");
257 print CONFIG
"# autogenerated by configure
260 INSTALL_PROGRAM?=install -c -m 755
261 INSTALL_LIB?= install -c -m 755
262 INSTALL_DATA?= install -c -m 644
264 # Where to install the binary
267 # Where to install the man pages
270 # Where to install the lib
273 # Where to install the configuration files
277 FEATURE_PYTHON=$python
279 # The OPTBIN variable is here to allow to use ocamlc.opt instead of
280 # ocaml, when it is available, which speeds up compilation. So
281 # if you want the fast version of the ocaml chain tools, set this var
282 # or setenv it to \".opt\" in your startup script.
286 pr2
"Modifying globals/config.ml";
287 pr2
"Generating appropriate links in python/ (python=$python)";
288 my $pythonprefix = $python ?
"yes_" : "no_";
289 `cd python; rm -f pycocci.ml pycocci_aux.ml;`;
290 `cd python; ln -s ${pythonprefix}pycocci.ml pycocci.ml; `;
291 `cd python; ln -s ${pythonprefix}pycocci_aux.ml pycocci_aux.ml;`;
292 `cd python; make depend`;
294 my $command = "perl -p -e 's#Not_found.\*#Not_found->\\\"$src\\\"#' globals/config.ml.in > globals/config.ml";
298 # Configuration of python with or without trac
300 `cd python/coccilib; ln -sf output_base.py output.py;`;
302 # Switch between implementation
304 pr2
"Selecting python trac extension";
305 `cd python/coccilib; ln -sf output_trac.py output.py;`;