bd012c0600dcc6deb5bc466c65c99f532cf087f2
2 ######################################################################
4 ######################################################################
6 # Yes I know about autoconf ... and autoconf sux.
8 # assume standard: diff
9 # assume standard: perl
11 #TODO python 2.5 and perhaps a --disable-python
13 #old: --with-menhir=/path/to/menhirLib or `ocamlfind query menhirLib`
18 "spatch -cocci_file demos/simple.cocci demos/simple.c";
20 ######################################################################
22 ######################################################################
24 my $prefix="/usr/local";
29 local $_ = join ' ', @ARGV;
32 /-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\n";
33 /--prefix=([^ ]*)/ and $prefix = $1;
34 /--without-python/ and $python = 0;
35 /--without-trac/ and $trac = 0;
36 /--with-trac/ and $trac = 1;
37 /--no-opt/ and $opt = "";
39 #if($ARGV[0] =~ "--prefix=(.*)") {
42 #if($ARGV[1] =~ "--without-python") {
46 my $src="$prefix/share/$project";
48 ######################################################################
50 ######################################################################
53 ######################################################################
55 ######################################################################
56 #BEGIN { die "need Perl 5 or greater" if $] < 5 ; }
59 sub pr2
{ print STDERR
"@_\n" }
64 while(<TMP
>) { push @list, "$_"; }
68 sub mapf
{ my ($f, $xs) = @_; [ map { &$f($_) } @
{$xs} ] }
69 sub plural
{ my ($e) = @_; if ($e > 1) { "s" } else { "" } }
71 sub check_config
{ my ($command, $expect, $msggood, $msgbad) = @_;
74 my $full = cat
($command);
75 my $res = join(" ", @
{$full});
77 if(notb
($res =~ $expect)) { $error++; pr2
"!!!! $msgbad !!!!"; }
82 ######################################################################
84 ######################################################################
85 pr2
"Checking your configuration.\n";
89 #---------------------------------------------------------------------
90 # Compilers and runtimes
91 #---------------------------------------------------------------------
93 check_config
("echo \"1;;\\n\" | ocaml |",
94 # "Objective(.*) 3.0[9]",
96 "OCaml (the wonderful language) is present.",
97 "The program ocaml is missing or is not a good version. We need at least 3.09",
100 if ($opt eq ".opt") {
101 my $opt_check = `which ocamlc.opt 2>&1 | cut -d' ' -f2`;
102 if($opt_check =~ "no") {
104 pr2
"Native version of OCaml not found";
107 pr2
"Native version of OCaml is present.";
111 #we have cached the result of menhir in the tgz we build.
114 # check_config("menhir --version |",
115 # "menhir, version 20071212",
116 ## "menhir, version 2006.*",
117 # "Menhir (the parser generator) is present.",
118 # "The program menhir is missing or is not a good version.",
122 #---------------------------------------------------------------
124 #---------------------------------------------------------------
128 $error += check_config
(
129 "make -v 2>&1 |grep Make|",
130 "GNU Make 3\.[0-9]+", #version 3.81
131 "make (gnu version) is present.",
132 "The program gnu make is missing or is not a good version.
137 #---------------------------------------------------------------------
138 # More developers tools
139 #---------------------------------------------------------------------
141 #---------------------------------------------------------------------
143 #---------------------------------------------------------------------
145 ######################################################################
146 # Generate config files (platform/portability issues)
147 ######################################################################
150 ######################################################################
151 # Generate globals files (features issues)
152 ######################################################################
154 ######################################################################
156 ######################################################################
161 ----------------------------------------------------------------------
162 !!!! There seems to have problem, we have found $error missing package" .
164 " . (($error > 1) ?
"Some of those packages" : "This package") .
165 " may be installed by picking " . ($error > 1 ?
"them" : "it") .
166 " in $project-dependencies.tgz available
167 on the $project website. !!!!
168 ----------------------------------------------------------------------
174 ----------------------------------------------------------------------
176 All seems fine for $project.
178 To compile $project type:
184 Then, to test $project simply type:
191 "To use the python SmPL feature you may have to set some environment variables.
193 export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$prefix/lib
194 export PYTHONPATH=\$PYTHONPATH:$src/python
198 ----------------------------------------------------------------------
204 ######################################################################
205 # Generating the configuration
206 ######################################################################
208 pr2
"$project target prefix: $prefix (you can use --prefix to override it)";
209 pr2
"Generating Makefile.config";
210 open(CONFIG
, ">Makefile.config");
211 print CONFIG
"# autogenerated by configure
213 # Where to install the binary
216 # Where to install the man pages
219 # Where to install the lib
222 # Where to install the configuration files
226 FEATURE_PYTHON=$python
228 # The OPTBIN variable is here to allow to use ocamlc.opt instead of
229 # ocaml, when it is available, which speeds up compilation. So
230 # if you want the fast version of the ocaml chain tools, set this var
231 # or setenv it to \".opt\" in your startup script.
235 pr2
"Modifying globals/config.ml";
236 pr2
"Generating appropriate links in python/ (python=$python)";
237 my $pythonprefix = $python ?
"yes_" : "no_";
238 `cd python; rm -f pycocci.ml pycocci_aux.ml;`;
239 `cd python; ln -s ${pythonprefix}pycocci.ml pycocci.ml; `;
240 `cd python; ln -s ${pythonprefix}pycocci_aux.ml pycocci_aux.ml;`;
241 `cd python; make depend`;
243 my $command = "perl -p -i -e 's#Not_found.\*#Not_found->\\\"$src\\\"#' globals/config.ml";
247 # Configuration of python with or without trac
249 `cd python/coccilib; ln -sf output_base.py output.py;`;
251 # Switch between implementation
253 pr2
"Selecting python trac extension";
254 `cd python/coccilib; ln -sf output_trac.py output.py;`;