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";
21 ######################################################################
23 ######################################################################
25 my $prefix="/usr/local";
28 local $_ = join ' ', @ARGV;
31 /-h/ || /--help/ and die "usage: $0 [--prefix=path] [--without-python]\n";
32 /--prefix=([^ ]*)/ and $prefix = $1;
33 /--without-python/ and $python = 0;
35 #if($ARGV[0] =~ "--prefix=(.*)") {
38 #if($ARGV[1] =~ "--without-python") {
42 my $src="$prefix/share/$project";
44 ######################################################################
46 ######################################################################
49 ######################################################################
51 ######################################################################
52 #BEGIN { die "need Perl 5 or greater" if $] < 5 ; }
55 sub pr2
{ print STDERR
"@_\n" }
60 while(<TMP
>) { push @list, "$_"; }
64 sub mapf
{ my ($f, $xs) = @_; [ map { &$f($_) } @
{$xs} ] }
65 sub plural
{ my ($e) = @_; if ($e > 1) { "s" } else { "" } }
67 sub check_config
{ my ($command, $expect, $msggood, $msgbad) = @_;
70 my $full = cat
($command);
71 my $res = join(" ", @
{$full});
73 if(notb
($res =~ $expect)) { $error++; pr2
"!!!! $msgbad !!!!"; }
78 ######################################################################
80 ######################################################################
81 pr2
"Checking your configuration.\n";
86 #---------------------------------------------------------------------
87 # Compilers and runtimes
88 #---------------------------------------------------------------------
90 check_config
("echo \"1;;\\n\" | ocaml |",
91 # "Objective(.*) 3.0[9]",
93 "OCaml (the wonderful language) is present.",
94 "The program ocaml is missing or is not a good version. We need at least 3.09",
97 #we have cached the result of menhir in the tgz we build.
100 # check_config("menhir --version |",
101 # "menhir, version 20071212",
102 ## "menhir, version 2006.*",
103 # "Menhir (the parser generator) is present.",
104 # "The program menhir is missing or is not a good version.",
108 #---------------------------------------------------------------
110 #---------------------------------------------------------------
114 $error += check_config
(
115 "make -v 2>&1 |grep Make|",
116 "GNU Make 3\.[0-9]+", #version 3.81
117 "make (gnu version) is present.",
118 "The program gnu make is missing or is not a good version.
123 #---------------------------------------------------------------------
124 # More developers tools
125 #---------------------------------------------------------------------
127 #---------------------------------------------------------------------
129 #---------------------------------------------------------------------
131 ######################################################################
132 # Generate config files (platform/portability issues)
133 ######################################################################
136 ######################################################################
137 # Generate globals files (features issues)
138 ######################################################################
140 ######################################################################
142 ######################################################################
147 ----------------------------------------------------------------------
148 !!!! There seems to have problem, we have found $error missing package" .
150 " . (($error > 1) ?
"Some of those packages" : "This package") .
151 " may be installed by picking " . ($error > 1 ?
"them" : "it") .
152 " in $project-dependencies.tgz available
153 on the $project website. !!!!
154 ----------------------------------------------------------------------
159 ----------------------------------------------------------------------
161 All seems fine for $project.
163 To compile $project type:
169 Then, to test $project simply type:
176 "To use the python SmPL feature you may have to set some environment variables.
178 export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$prefix/lib
179 export PYTHONPATH=\$PYTHONPATH:$src/python
183 ----------------------------------------------------------------------
189 ######################################################################
190 # Generating the configuration
191 ######################################################################
193 pr2
"$project target prefix: $prefix (you can use --prefix to override it)";
194 pr2
"Generating Makefile.config";
195 open(CONFIG
, ">Makefile.config");
196 print CONFIG
"# autogenerated by configure
198 # Where to install the binary
201 # Where to install the man pages
204 # Where to install the lib
207 # Where to install the configuration files
211 FEATURE_PYTHON=$python
214 pr2
"Modifying globals/config.ml";
215 pr2
"Generating appropriate links in python/ (python=$python)";
216 my $pythonprefix = $python ?
"yes_" : "no_";
217 `cd python; rm -f pycocci.ml pycocci_aux.ml;`;
218 `cd python; ln -s ${pythonprefix}pycocci.ml pycocci.ml; `;
219 `cd python; ln -s ${pythonprefix}pycocci_aux.ml pycocci_aux.ml;`;
220 `cd python; make depend`;
222 my $command = "perl -p -i -e 's#Not_found.\*#Not_found->\\\"$src\\\"#' globals/config.ml";