forked from coccinelle/coccinelle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·227 lines (168 loc) · 6.27 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/usr/bin/perl
######################################################################
# Prelude
######################################################################
# Yes I know about autoconf ... and autoconf sux.
# assume standard: diff
# assume standard: perl
#TODO python 2.5 and perhaps a --disable-python
#old: --with-menhir=/path/to/menhirLib or `ocamlfind query menhirLib`
my $project =
"coccinelle";
my $projectcmdline =
"spatch -cocci_file demos/simple.cocci demos/simple.c";
######################################################################
# Options
######################################################################
my $prefix="/usr/local";
my $python=1;
local $_ = join ' ', @ARGV;
# Parse options
/-h/ || /--help/ and die "usage: $0 [--prefix=path] [--without-python]\n";
/--prefix=([^ ]*)/ and $prefix = $1;
/--without-python/ and $python = 0;
#if($ARGV[0] =~ "--prefix=(.*)") {
# $prefix = $1;
#}
#if($ARGV[1] =~ "--without-python") {
# $python = 0;
#}
my $src="$prefix/share/$project";
######################################################################
# Side effects
######################################################################
######################################################################
# Helpers
######################################################################
#BEGIN { die "need Perl 5 or greater" if $] < 5 ; }
#use Common;
sub pr2 { print STDERR "@_\n" }
sub cat {
my ($what) = @_;
my @list;
open(TMP, $what);
while(<TMP>) { push @list, "$_"; }
\@list;
}
sub notb { !$_[0] }
sub mapf { my ($f, $xs) = @_; [ map { &$f($_) } @{$xs} ] }
sub plural { my ($e) = @_; if ($e > 1) { "s" } else { "" } }
sub check_config { my ($command, $expect, $msggood, $msgbad) = @_;
my $error = 0;
my $full = cat($command);
my $res = join(" ", @{$full});
# pr2 $res;
if(notb($res =~ $expect)) { $error++; pr2 "!!!! $msgbad !!!!"; }
else { pr2 $msggood }
return $error;
}
######################################################################
# Let's go
######################################################################
pr2 "Checking your configuration.\n";
my $error = 0;
#---------------------------------------------------------------------
# Compilers and runtimes
#---------------------------------------------------------------------
$error +=
check_config("echo \"1;;\\n\" | ocaml |",
# "Objective(.*) 3.0[9]",
"Objective(.*) 3.",
"OCaml (the wonderful language) is present.",
"The program ocaml is missing or is not a good version. We need at least 3.09",
);
#we have cached the result of menhir in the tgz we build.
#$error +=
# check_config("menhir --version |",
# "menhir, version 20071212",
## "menhir, version 2006.*",
# "Menhir (the parser generator) is present.",
# "The program menhir is missing or is not a good version.",
# );
#---------------------------------------------------------------
# Developers tools
#---------------------------------------------------------------
pr2 "";
$error += check_config(
"make -v 2>&1 |grep Make|",
"GNU Make 3\.[0-9]+", #version 3.81
"make (gnu version) is present.",
"The program gnu make is missing or is not a good version.
We need 3.XX",
);
#---------------------------------------------------------------------
# More developers tools
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# Librairies
#---------------------------------------------------------------------
######################################################################
# Generate config files (platform/portability issues)
######################################################################
######################################################################
# Generate globals files (features issues)
######################################################################
######################################################################
# Diagnostic
######################################################################
if($error) {
pr2 "
----------------------------------------------------------------------
!!!! There seems to have problem, we have found $error missing package" .
plural($error) . ".
" . (($error > 1) ? "Some of those packages" : "This package") .
" may be installed by picking " . ($error > 1 ? "them" : "it") .
" in $project-dependencies.tgz available
on the $project website. !!!!
----------------------------------------------------------------------
";
} else {
pr2 "
----------------------------------------------------------------------
All seems fine for $project.
To compile $project type:
make depend; make
To install type:
make install
Then, to test $project simply type:
$projectcmdline
";
if($python) {
pr2
"To use the python SmPL feature you may have to set some environment variables.
For bash do:
export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$prefix/lib
export PYTHONPATH=\$PYTHONPATH:$src/python
"
}
pr2 "
----------------------------------------------------------------------
";
}
######################################################################
# Generating the configuration
######################################################################
pr2 "$project target prefix: $prefix (you can use --prefix to override it)";
pr2 "Generating Makefile.config";
open(CONFIG, ">Makefile.config");
print CONFIG "# autogenerated by configure
# Where to install the binary
BINDIR=$prefix/bin
# Where to install the man pages
MANDIR=$prefix/man
# Where to install the lib
LIBDIR=$prefix/lib
# Where to install the configuration files
SHAREDIR=$src
# Features
FEATURE_PYTHON=$python
";
pr2 "Modifying globals/config.ml";
pr2 "Generating appropriate links in python/ (python=$python)";
my $pythonprefix = $python ? "yes_" : "no_";
`cd python; rm -f pycocci.ml pycocci_aux.ml;`;
`cd python; ln -s ${pythonprefix}pycocci.ml pycocci.ml; `;
`cd python; ln -s ${pythonprefix}pycocci_aux.ml pycocci_aux.ml;`;
`cd python; make depend`;
my $command = "perl -p -i -e 's#Not_found.\*#Not_found->\\\"$src\\\"#' globals/config.ml";
`$command`;