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 # need latex and hevea if want to compile the documentation
18 #old: --with-menhir=/path/to/menhirLib or `ocamlfind query menhirLib`
23 "spatch -sp_file demos/simple.cocci demos/simple.c -o /tmp/new_simple.c";
25 ######################################################################
27 ######################################################################
29 my $prefix="/usr/local";
35 local $_ = join ' ', @ARGV;
38 /-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";
39 /--prefix=([^ ]*)/ and $prefix = $1;
40 /--without-python/ and $python = 0;
41 /--without-trac/ and $trac = 0;
42 /--with-trac/ and $trac = 1;
43 /--no-opt/ and $opt = "";
44 /--opt/ and $opt = ".opt";
46 #tarzan by default (used by score file parsing and now also for sexp_ast_c.ml)
49 #if($ARGV[0] =~ "--prefix=(.*)") {
52 #if($ARGV[1] =~ "--without-python") {
56 my $src="$prefix/share/$project";
58 ######################################################################
60 ######################################################################
63 ######################################################################
65 ######################################################################
66 #BEGIN { die "need Perl 5 or greater" if $] < 5 ; }
69 sub pr2
{ print STDERR
"@_\n" }
74 while(<TMP
>) { push @list, "$_"; }
78 sub mapf
{ my ($f, $xs) = @_; [ map { &$f($_) } @
{$xs} ] }
79 sub plural
{ my ($e) = @_; if ($e > 1) { "s" } else { "" } }
81 sub check_config
{ my ($command, $expect, $msggood, $msgbad) = @_;
84 my $full = cat
($command);
85 my $res = join(" ", @
{$full});
87 if(notb
($res =~ $expect)) { $error++; pr2
"!!!! $msgbad !!!!"; }
92 ######################################################################
94 ######################################################################
95 pr2
"Checking your configuration.\n";
99 #---------------------------------------------------------------------
100 # Compilers and runtimes
101 #---------------------------------------------------------------------
103 check_config
("echo \"1;;\\n\" | ocaml |",
104 # "Objective(.*) 3.0[9]",
106 "OCaml (the wonderful language) is present.",
107 "The program ocaml is missing or is not a good version. We need at least 3.09",
110 if ($opt eq ".opt") {
111 my $opt_check = `which ocamlc.opt 2> /dev/null`;
112 if($opt_check =~ "/ocamlc.opt\$") {
113 pr2
"ocamlc.opt is present.";
117 pr2
"ocamlc.opt not found";
120 my $opt_check = `which ocamlopt.opt 2> /dev/null`;
121 if($opt_check =~ "/ocamlopt.opt\$") {
122 pr2
"ocamlopt.opt is present.";
126 pr2
"ocamlopt.opt not found";
129 my $opt_check = `which ocamldep.opt 2> /dev/null`;
130 if($opt_check =~ "/ocamldep.opt\$") {
131 pr2
"ocamldep.opt is present.";
135 pr2
"ocamldep.opt not found";
138 my $opt_check = `which ocamllex.opt 2> /dev/null`;
139 if($opt_check =~ "/ocamllex.opt\$") {
140 pr2
"ocamllex.opt is present.";
144 pr2
"ocamllex.opt not found";
148 pr2
"At least one native OCaml tool have not been found.";
149 pr2
"Desactivation of all native OCaml tools for compilation.";
153 #we have cached the result of menhir in the tgz we build.
156 # check_config("menhir --version |",
157 # "menhir, version 20071212",
158 ## "menhir, version 2006.*",
159 # "Menhir (the parser generator) is present.",
160 # "The program menhir is missing or is not a good version.",
164 #---------------------------------------------------------------
166 #---------------------------------------------------------------
170 $error += check_config
(
171 "make -v 2>&1 |grep Make|",
172 "GNU Make [^0-9]*3\.[0-9]+.*", #version 3.79.1, 3.81
173 "make (gnu version) is present.",
174 "The program gnu make is missing or is not a good version.
179 #---------------------------------------------------------------------
180 # More developers tools
181 #---------------------------------------------------------------------
183 #---------------------------------------------------------------------
185 #---------------------------------------------------------------------
187 ######################################################################
188 # Generate config files (platform/portability issues)
189 ######################################################################
192 ######################################################################
193 # Generate globals files (features issues)
194 ######################################################################
196 ######################################################################
198 ######################################################################
203 ----------------------------------------------------------------------
204 !!!! There seems to have problem, we have found $error missing package" .
206 " . (($error > 1) ?
"Some of those packages" : "This package") .
207 " may be installed by picking " . ($error > 1 ?
"them" : "it") .
208 " in $project-dependencies.tgz available
209 on the $project website. !!!!
210 ----------------------------------------------------------------------
214 #pad: before the message was saying (make depend); make all
215 # I found this confusing so I removed it.
219 ----------------------------------------------------------------------
221 All seems fine for $project.
223 To compile $project type:
227 Or alternatively, for the optimized version:
229 If you want both, you could use:
236 Then, to test $project simply type:
243 "To use the python SmPL feature you may have to set some environment variables.
245 export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$prefix/lib
246 export PYTHONPATH=\$PYTHONPATH:$src/python
250 ----------------------------------------------------------------------
256 ######################################################################
257 # Generating the configuration
258 ######################################################################
260 pr2
"$project target prefix: $prefix (you can use --prefix to override it)";
261 pr2
"Generating Makefile.config";
262 open(CONFIG
, ">Makefile.config");
263 print CONFIG
"# autogenerated by configure
266 INSTALL_PROGRAM?=install -c -m 755
267 INSTALL_LIB?= install -c -m 755
268 INSTALL_DATA?= install -c -m 644
270 # Where to install the binary
273 # Where to install the man pages
276 # Where to install the lib
279 # Where to install the configuration files
283 FEATURE_PYTHON=$python
284 FEATURE_TARZAN=$tarzan
286 # The OPTBIN variable is here to allow to use ocamlc.opt instead of
287 # ocaml, when it is available, which speeds up compilation. So
288 # if you want the fast version of the ocaml chain tools, set this var
289 # or setenv it to \".opt\" in your startup script.
293 pr2
"Modifying globals/config.ml";
294 pr2
"Generating appropriate links in python/ (python=$python)";
295 my $pythonprefix = $python ?
"yes_" : "no_";
296 `cd python; rm -f pycocci.ml pycocci_aux.ml;`;
297 `cd python; ln -s ${pythonprefix}pycocci.ml pycocci.ml; `;
298 `cd python; ln -s ${pythonprefix}pycocci_aux.ml pycocci_aux.ml;`;
299 `cd python; make depend`;
301 my $command = "perl -p -e 's#Not_found.\*#Not_found->\\\"$src\\\"#' globals/config.ml.in > globals/config.ml";
305 # Configuration of python with or without trac
307 `cd python/coccilib; ln -sf output_base.py output.py;`;
309 # Switch between implementation
311 pr2
"Selecting python trac extension";
312 `cd python/coccilib; ln -sf output_trac.py output.py;`;