477b780911efc75af948a8566e665a0a7ba778b3
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\t--opt\tUse 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 = "";
38 /--opt/ and $opt = ".opt";
40 #if($ARGV[0] =~ "--prefix=(.*)") {
43 #if($ARGV[1] =~ "--without-python") {
47 my $src="$prefix/share/$project";
49 ######################################################################
51 ######################################################################
54 ######################################################################
56 ######################################################################
57 #BEGIN { die "need Perl 5 or greater" if $] < 5 ; }
60 sub pr2
{ print STDERR
"@_\n" }
65 while(<TMP
>) { push @list, "$_"; }
69 sub mapf
{ my ($f, $xs) = @_; [ map { &$f($_) } @
{$xs} ] }
70 sub plural
{ my ($e) = @_; if ($e > 1) { "s" } else { "" } }
72 sub check_config
{ my ($command, $expect, $msggood, $msgbad) = @_;
75 my $full = cat
($command);
76 my $res = join(" ", @
{$full});
78 if(notb
($res =~ $expect)) { $error++; pr2
"!!!! $msgbad !!!!"; }
83 ######################################################################
85 ######################################################################
86 pr2
"Checking your configuration.\n";
90 #---------------------------------------------------------------------
91 # Compilers and runtimes
92 #---------------------------------------------------------------------
94 check_config
("echo \"1;;\\n\" | ocaml |",
95 # "Objective(.*) 3.0[9]",
97 "OCaml (the wonderful language) is present.",
98 "The program ocaml is missing or is not a good version. We need at least 3.09",
101 if ($opt eq ".opt") {
102 my $opt_check = `which ocamlc.opt 2> /dev/null`;
103 if($opt_check =~ "/ocamlc.opt\$") {
104 pr2
"ocamlc.opt is present.";
108 pr2
"ocamlc.opt not found";
111 my $opt_check = `which ocamlopt.opt 2> /dev/null`;
112 if($opt_check =~ "/ocamlopt.opt\$") {
113 pr2
"ocamlopt.opt is present.";
117 pr2
"ocamlopt.opt not found";
120 my $opt_check = `which ocamldep.opt 2> /dev/null`;
121 if($opt_check =~ "/ocamldep.opt\$") {
122 pr2
"ocamldep.opt is present.";
126 pr2
"ocamldep.opt not found";
129 my $opt_check = `which ocamllex.opt 2> /dev/null`;
130 if($opt_check =~ "/ocamllex.opt\$") {
131 pr2
"ocamllex.opt is present.";
135 pr2
"ocamllex.opt not found";
139 pr2
"At least one native OCaml tool have not been found.";
140 pr2
"Desactivation of all native OCaml tools for compilation.";
144 #we have cached the result of menhir in the tgz we build.
147 # check_config("menhir --version |",
148 # "menhir, version 20071212",
149 ## "menhir, version 2006.*",
150 # "Menhir (the parser generator) is present.",
151 # "The program menhir is missing or is not a good version.",
155 #---------------------------------------------------------------
157 #---------------------------------------------------------------
161 $error += check_config
(
162 "make -v 2>&1 |grep Make|",
163 "GNU Make 3\.[0-9]+", #version 3.81
164 "make (gnu version) is present.",
165 "The program gnu make is missing or is not a good version.
170 #---------------------------------------------------------------------
171 # More developers tools
172 #---------------------------------------------------------------------
174 #---------------------------------------------------------------------
176 #---------------------------------------------------------------------
178 ######################################################################
179 # Generate config files (platform/portability issues)
180 ######################################################################
183 ######################################################################
184 # Generate globals files (features issues)
185 ######################################################################
187 ######################################################################
189 ######################################################################
194 ----------------------------------------------------------------------
195 !!!! There seems to have problem, we have found $error missing package" .
197 " . (($error > 1) ?
"Some of those packages" : "This package") .
198 " may be installed by picking " . ($error > 1 ?
"them" : "it") .
199 " in $project-dependencies.tgz available
200 on the $project website. !!!!
201 ----------------------------------------------------------------------
207 ----------------------------------------------------------------------
209 All seems fine for $project.
211 To compile $project type:
212 (make depend); make all
213 or alternatively, for the optimized version:
214 (make depend); make all.opt
215 If you want both, you could use:
216 (make depend); make world
221 Then, to test $project simply type:
228 "To use the python SmPL feature you may have to set some environment variables.
230 export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$prefix/lib
231 export PYTHONPATH=\$PYTHONPATH:$src/python
235 ----------------------------------------------------------------------
241 ######################################################################
242 # Generating the configuration
243 ######################################################################
245 pr2
"$project target prefix: $prefix (you can use --prefix to override it)";
246 pr2
"Generating Makefile.config";
247 open(CONFIG
, ">Makefile.config");
248 print CONFIG
"# autogenerated by configure
251 INSTALL_PROGRAM?=install -c -m 755
252 INSTALL_LIB?= install -c -m 755
253 INSTALL_DATA?= install -c -m 644
255 # Where to install the binary
258 # Where to install the man pages
261 # Where to install the lib
264 # Where to install the configuration files
268 FEATURE_PYTHON=$python
270 # The OPTBIN variable is here to allow to use ocamlc.opt instead of
271 # ocaml, when it is available, which speeds up compilation. So
272 # if you want the fast version of the ocaml chain tools, set this var
273 # or setenv it to \".opt\" in your startup script.
277 pr2
"Modifying globals/config.ml";
278 pr2
"Generating appropriate links in python/ (python=$python)";
279 my $pythonprefix = $python ?
"yes_" : "no_";
280 `cd python; rm -f pycocci.ml pycocci_aux.ml;`;
281 `cd python; ln -s ${pythonprefix}pycocci.ml pycocci.ml; `;
282 `cd python; ln -s ${pythonprefix}pycocci_aux.ml pycocci_aux.ml;`;
283 `cd python; make depend`;
285 my $command = "perl -p -e 's#Not_found.\*#Not_found->\\\"$src\\\"#' globals/config.ml.in > globals/config.ml";
289 # Configuration of python with or without trac
291 `cd python/coccilib; ln -sf output_base.py output.py;`;
293 # Switch between implementation
295 pr2
"Selecting python trac extension";
296 `cd python/coccilib; ln -sf output_trac.py output.py;`;