Skip to content
This repository
Newer
Older
100755 381 lines (299 sloc) 10.629 kb
8634b74a » pad
2010-09-22 initial import into fresh git repo.
1 #!/usr/bin/perl
2 use strict;
3
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
4 # this is not available in some distro :(
8634b74a » pad
2010-09-22 initial import into fresh git repo.
5 use Getopt::Long;
6 use Pod::Usage;
7
8 ######################################################################
9 # Prelude
10 ######################################################################
11
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
12 # Yes I know about autoconf ... and autoconf sucks.
8634b74a » pad
2010-09-22 initial import into fresh git repo.
13
016f9c48 » aryx
2012-06-14 * configure: better error message. Exit earlier.
14 # We do not check for the following programs; we assume they are standard:
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
15 # - binutils, gcc, as, ld (the GNU toolchain)
06dcb644 » aryx
2013-10-05 * configure: allow 4.00 and 4.01
16 # - make, perl, bash
016f9c48 » aryx
2012-06-14 * configure: better error message. Exit earlier.
17 # - diffutils, fileutils, findutils, grep, patchutils, sh-utils
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
18 #
6dbcc033 » aryx
2013-11-13 * configure: cleanup
19 #todo:
914185f7 » aryx
2014-02-18 * configure: comment
20 # - findutils? we need a good GNU find, not the macos find
06dcb644 » aryx
2013-10-05 * configure: allow 4.00 and 4.01
21 # which adds some extra '//' in paths which bothers pfff
6dbcc033 » aryx
2013-11-13 * configure: cleanup
22 # - sharutils still?, for obrowser/ocsigen use of uuencode
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
23 #
24 # If you want to run the tests you will also need:
cd9d0091 » aryx
2013-01-08 * data/php_stdlib/: split in some files, so some can be skipped in sk…
25 # - swipl
26 # - javac
27
8634b74a » pad
2010-09-22 initial import into fresh git repo.
28 my $project =
29 "pfff";
30 my $projectcmdline =
f7a5f746 » aryx
2011-03-04 configure: comments
31 "./pfff -dump_php demos/foo.php";
8634b74a » pad
2010-09-22 initial import into fresh git repo.
32
33 ######################################################################
34 # Options
35 ######################################################################
36
37 my $prefix="/usr/local";
38
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
39 # cairo/gtk, for codemap and codegraph
40 my $visual=1;
41
42 # lang_bytecode/ brings many dependencies (extlib, ptrees, ocamlzip), which
43 # in turns require zlib.h, so it's a configuration option
44 # (todo: could auto detect)
0a5c8e53 » aryx
2014-03-04 make lang_bytecode/ optional in configure; also cleanup stuff
45 my $bytecode=1;
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
46
47 # lang_cmt/ also requires compiler-libs and with the many changes in the
48 # .cmt format, this can easily break compilations, so it's also
49 # a configuration option.
07114ba3 » aryx
2014-03-04 * configure: new option --nocmt
50 my $cmt=1;
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
51
52 # todo: still used?
8634b74a » pad
2010-09-22 initial import into fresh git repo.
53 my $facebook=0;
54
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
55 # adjusted automatically based on local ocaml configuration
56 my $opt= ""; # ocamlc.opt?
57 my $ocamlc_flags = ""; #ocamlc -bin-annot?
58 my $ocaml_version = 3112;
59
60
8634b74a » pad
2010-09-22 initial import into fresh git repo.
61 my $man = 0;
62 my $help = 0;
63
016f9c48 » aryx
2012-06-14 * configure: better error message. Exit earlier.
64 # See http://perldoc.perl.org/Getopt/Long.html
8634b74a » pad
2010-09-22 initial import into fresh git repo.
65 # coupling: if add options here, add an explanation at the bottom of this file
016f9c48 » aryx
2012-06-14 * configure: better error message. Exit earlier.
66 # too. Later you may also add something in the documentation latex file
67 # (or use LP).
8634b74a » pad
2010-09-22 initial import into fresh git repo.
68 GetOptions (
69 "prefix=s" => \$prefix,
06dcb644 » aryx
2013-10-05 * configure: allow 4.00 and 4.01
70 "visual!" => \$visual,
0a5c8e53 » aryx
2014-03-04 make lang_bytecode/ optional in configure; also cleanup stuff
71 "bytecode!" => \$bytecode,
07114ba3 » aryx
2014-03-04 * configure: new option --nocmt
72 "cmt!" => \$cmt,
8634b74a » pad
2010-09-22 initial import into fresh git repo.
73 "facebook" => sub {
74 $facebook = 1;
6dbcc033 » aryx
2013-11-13 * configure: cleanup
75 $visual = 0;
8634b74a » pad
2010-09-22 initial import into fresh git repo.
76 },
77 'help|?' => \$help,
78 'man' => \$man
79 ) or pod2usage(2);
80 #or die "$0: GetOptions: $!";
81
82 pod2usage(1) if $help;
83 pod2usage(-exitstatus => 0, -verbose => 2) if $man;
84
85 my $src="$prefix/share/$project";
86
6dbcc033 » aryx
2013-11-13 * configure: cleanup
87 # Implicit dependencies:
88 if ($facebook) { }
8634b74a » pad
2010-09-22 initial import into fresh git repo.
89
90 ######################################################################
91 # Helpers
92 ######################################################################
93 BEGIN { die "need Perl 5 or greater" if $] < 5 ; }
94
95 #use Common;
96 sub pr2 { print STDERR "@_\n" }
97 sub cat {
98 my ($what) = @_;
99 my @list;
100 open(TMP, $what);
101 while(<TMP>) { push @list, "$_"; }
102 \@list;
103 }
104 sub notb { !$_[0] }
105 sub mapf { my ($f, $xs) = @_; [ map { &$f($_) } @{$xs} ] }
106 sub plural { my ($e) = @_; if ($e > 1) { "s" } else { "" } }
107
108 sub check_config { my ($command, $expect, $msggood, $msgbad) = @_;
109 my $error = 0;
110
111 my $full = cat($command);
112 my $res = join(" ", @{$full});
113 # pr2 $res;
114 if(notb($res =~ $expect)) { $error++; pr2 "!!!! $msgbad !!!!"; }
115 else { pr2 $msggood }
116 return $error;
117 }
016f9c48 » aryx
2012-06-14 * configure: better error message. Exit earlier.
118
119 sub show_error_msg_and_exit_if_error {
120 my ($error) = @_;
121 if($error) {
122 pr2 "
123 ----------------------------------------------------------------------
124 !!!! There seems to have a problem, we have found a missing program.
125 Have a look at install.txt and the install_xxx.txt corresponding to your
126 OS.!!!!
127 ----------------------------------------------------------------------
128 ";
129 exit 1;
130 }
131 #plural($error) . ".
132 #" .
133 #" . (($error > 1) ? "Some of those packages" : "This package") .
134 # " may be installed by picking " . ($error > 1 ? "them" : "it") .
135 # " in $project-dependencies.tgz available
136 #on the $project website. !!!!
137 }
138
139 sub show_missing_package_error_msg {
140 my ($error2) = @_;
141 pr2 "
142 ----------------------------------------------------------------------
143 !!!! You can try to compile and test $project,
144 but some features or plugins may be missing. !!!!\n
145 We have found $error2 missing package" . plural($error2) . ". " .
146 #(($error2 > 1) ? "Some of those packages" : "This package") .
147 #" may be installed
148 #by picking " . ($error2 > 1 ? "them" : "it") .
149 #" in $project-dependencies.tgz available on the $project website.
150 #";
151 "
152 Have a look at the install_xxx.txt corresponding to your OS.
153 ";
154 }
155
8634b74a » pad
2010-09-22 initial import into fresh git repo.
156 ######################################################################
157 # Let's go
158 ######################################################################
159
160 pr2 "Checking your configuration.\n";
161
6dbcc033 » aryx
2013-11-13 * configure: cleanup
162 # hard error, missing programs
8634b74a » pad
2010-09-22 initial import into fresh git repo.
163 my $error = 0;
6dbcc033 » aryx
2013-11-13 * configure: cleanup
164 # soft error, missing libraries, can not probably compile every pfff components
8634b74a » pad
2010-09-22 initial import into fresh git repo.
165 my $error2 = 0;
166
9ae9f4ad » stass
2011-12-12 - Fix configure on FreeBSD.
167 my $arch = `uname`;
168
8634b74a » pad
2010-09-22 initial import into fresh git repo.
169 #---------------------------------------------------------------------
170 # Compilers and runtimes
171 #---------------------------------------------------------------------
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
172 # We need at least 3.12 because I use the forall 'a. new typing feature
016f9c48 » aryx
2012-06-14 * configure: better error message. Exit earlier.
173 # as well as the '_' pattern in records (in my code but also in lib-sexp/)
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
174 # We optionaly need 4.00 or 4.01 for codegraph for ocaml code using the .cmt
8634b74a » pad
2010-09-22 initial import into fresh git repo.
175 $error +=
176 check_config("echo \"1;;\\n\" | ocaml |",
06dcb644 » aryx
2013-10-05 * configure: allow 4.00 and 4.01
177 "(Objective|OCaml)(.*) ([34]\.*.*)",
8634b74a » pad
2010-09-22 initial import into fresh git repo.
178 "OCaml (the wonderful language) is present.",
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
179 "The program ocaml is missing or is not a good version. We need at least 3.12",
8634b74a » pad
2010-09-22 initial import into fresh git repo.
180 );
016f9c48 » aryx
2012-06-14 * configure: better error message. Exit earlier.
181 show_error_msg_and_exit_if_error($error);
8634b74a » pad
2010-09-22 initial import into fresh git repo.
182
06dcb644 » aryx
2013-10-05 * configure: allow 4.00 and 4.01
183 my $command = "echo \"1;;\\n\" | ocaml |";
184 my $full = cat($command);
185 my $res = join(" ", @{$full});
186 if ($res =~ /(Objective|OCaml)(.*) ([34])\.([0-9]+).([0-9]+)/) {
187 my $major = $3;
188 my $minor = $4;
189 my $other = $5;
190 $ocaml_version = $major * 1000 + $minor * 10 + $other;
191 } else {
192 die "wrong version of ocaml";
193 }
8634b74a » pad
2010-09-22 initial import into fresh git repo.
194
c468ee29 » aryx
2014-03-12 * configure: works again with 3.12
195 # allow to use ocamlc.opt instead of ocamlc, which speeds up compilation
196 if (`which ocamlc.opt` && `which ocamlopt.opt`) {
197 $opt = ".opt";
198 }
199
200 # -bin-annot is for codegraph, it needs ocaml 4.00,
201 # -absname is for tuareg mode under my mac, it also needs ocaml 4.00
202 if($ocaml_version >= 4000) {
203 $ocamlc_flags="-bin-annot -absname";
204 } else {
205 $cmt=0;
206 }
207
8634b74a » pad
2010-09-22 initial import into fresh git repo.
208 #---------------------------------------------------------------
209 # Developers tools
210 #---------------------------------------------------------------
211
9ae9f4ad » stass
2011-12-12 - Fix configure on FreeBSD.
212 my $MAKE_PROGRAM = "make";
213 if($arch =~ /FreeBSD/) {
214 $MAKE_PROGRAM = "gmake";
215 }
216
5844e741 » kennknowles
2012-08-23 On OSX, f brew present, use /usr/local instead of /opt/local
217 my $BREW_PROGRAM = "";
218 if($arch =~ /Darwin/) {
219 $BREW_PROGRAM = `which brew`;
220 }
221
8634b74a » pad
2010-09-22 initial import into fresh git repo.
222 $error += check_config(
9ae9f4ad » stass
2011-12-12 - Fix configure on FreeBSD.
223 "$MAKE_PROGRAM -v 2>&1 |grep --colour=never Make|",
0194fa2e » tuncer
2013-10-16 configure: support GNU Make 4.x
224 "GNU Make [3|4]\.[0-9]+", #version 3.81
8634b74a » pad
2010-09-22 initial import into fresh git repo.
225 "make (gnu version) is present.",
226 "The program gnu make is missing or is not a good version.
0194fa2e » tuncer
2013-10-16 configure: support GNU Make 4.x
227 We need at least 3.XX",
8634b74a » pad
2010-09-22 initial import into fresh git repo.
228 );
016f9c48 » aryx
2012-06-14 * configure: better error message. Exit earlier.
229 show_error_msg_and_exit_if_error($error);
8634b74a » pad
2010-09-22 initial import into fresh git repo.
230
231 #---------------------------------------------------------------------
232 # More developers tools
233 #---------------------------------------------------------------------
234
235 #---------------------------------------------------------------------
236 # Librairies
237 #---------------------------------------------------------------------
238
239 # if darwin or cygwin then could just modify this variable ? enough ?
240 my $prefix_distrib = "/usr";
241
5844e741 » kennknowles
2012-08-23 On OSX, f brew present, use /usr/local instead of /opt/local
242 if( ($arch =~ /FreeBSD/) || (($arch =~ /Darwin/) && ($BREW_PROGRAM)) ) {
4b92d150 » Yoann Padioleau
2013-05-29 * configure: try better handle brew
243 $prefix_distrib = "/usr/local";
244 } elsif ($arch =~ /Darwin/) {
245 $prefix_distrib = "/opt/local";
9ae9f4ad » stass
2011-12-12 - Fix configure on FreeBSD.
246 }
247
439c6cb3 » pad
2010-10-08 configure: add comment about ocamlgraph
248 # The default ocamlgraph configure generate Makefiles that uses some -pack
249 # and certain module names like Graph that conflicts with other pfff modules
250 # so right now the Makefile is hand-crafted.
251
6dbcc033 » aryx
2013-11-13 * configure: cleanup
252 if($visual) {
33491d97 » aryx
2013-12-03 * configure: less output, better output
253 pr2 "Configuring ocamlgtk (see /tmp/ocamlgtk.log).";
0e09f74c » aryx
2013-12-11 * configure: do not use &>
254 my $err = system("cd external/ocamlgtk; ./configure > /tmp/ocamlgtk.log");
6dbcc033 » aryx
2013-11-13 * configure: cleanup
255 if ($err) { $visual = 0; $error2++; }
26cc32a0 » pad
2010-09-23 Makefiles and configure: make cairo+gtk the default.
256
33491d97 » aryx
2013-12-03 * configure: less output, better output
257 pr2 "Configuring ocamlcairo (see /tmp/ocamlcairo.log).";
3aa2ef99 » pad
2011-02-18 configure: remove the FEATURES when the corresponding check_config
258 my $err = system("cd external/ocamlcairo;
0e09f74c » aryx
2013-12-11 * configure: do not use &>
259 LABLGTKDIR=../../ocamlgtk/src ./configure --with-gtk > /tmp/ocamlcairo.log");
3aa2ef99 » pad
2011-02-18 configure: remove the FEATURES when the corresponding check_config
260 if ($err) { $visual = 0; $error2++; }
26cc32a0 » pad
2010-09-23 Makefiles and configure: make cairo+gtk the default.
261 }
262
8634b74a » pad
2010-09-22 initial import into fresh git repo.
263 ######################################################################
264 # Generating the configuration
265 ######################################################################
266
6dbcc033 » aryx
2013-11-13 * configure: cleanup
267 pr2 "";
8634b74a » pad
2010-09-22 initial import into fresh git repo.
268 pr2 "$project target prefix: $prefix (you can use --prefix to override it)";
07114ba3 » aryx
2014-03-04 * configure: new option --nocmt
269 pr2 "Generating Makefile.config (VISUAL=$visual, BYTECODE=$bytecode, CMT=$cmt) (see also configure --help)";
8634b74a » pad
2010-09-22 initial import into fresh git repo.
270 open(CONFIG, ">Makefile.config");
271 print CONFIG "# autogenerated by configure
272
273 # Where to install the binary
274 BINDIR=$prefix/bin
275
276 # Where to install the man pages
277 MANDIR=$prefix/man
278
279 # Where to install the lib
280 LIBDIR=$prefix/lib
281
282 # Where to install the configuration files
283 SHAREDIR=$src
284
285 # Features
286 FEATURE_VISUAL=$visual
287 FEATURE_FACEBOOK=$facebook
288
0a5c8e53 » aryx
2014-03-04 make lang_bytecode/ optional in configure; also cleanup stuff
289 FEATURE_BYTECODE=$bytecode
07114ba3 » aryx
2014-03-04 * configure: new option --nocmt
290 FEATURE_CMT=$cmt
0a5c8e53 » aryx
2014-03-04 make lang_bytecode/ optional in configure; also cleanup stuff
291
06dcb644 » aryx
2013-10-05 * configure: allow 4.00 and 4.01
292 OPTBIN=$opt
293 OCAMLCFLAGS_EXTRA=$ocamlc_flags
294 OCAMLVERSION=$ocaml_version
295 ";
8634b74a » pad
2010-09-22 initial import into fresh git repo.
296
297
298 pr2 "Generating commons/features.ml";
6dbcc033 » aryx
2013-11-13 * configure: cleanup
299 `cpp -DFEATURE_VISUAL=$visual commons/features.ml.in > commons/features.ml`;
8634b74a » pad
2010-09-22 initial import into fresh git repo.
300
d5aa6a98 » aryx
2012-11-19 integrate compiler-libs and CEs
301 pr2 "Generating globals/config_pfff.ml";
06dcb644 » aryx
2013-10-05 * configure: allow 4.00 and 4.01
302 `perl -p -e 's#Not_found1.\*#Not_found->\\\"$src\\\"#' globals/config_pfff.ml.in > globals/config_pfff.ml`;
6dbcc033 » aryx
2013-11-13 * configure: cleanup
303
6ce8eb21 » aryx
2012-02-08 * main_codemap.ml: use of the logger
304 if($facebook) {
305 my ($server) = `cat facebook/pfff_logger.config`;
d5aa6a98 » aryx
2012-11-19 integrate compiler-libs and CEs
306 `perl -p -i -e 's#Not_found2.\*#Not_found-> Some \\\"$server\\\"#' globals/config_pfff.ml`;
6ce8eb21 » aryx
2012-02-08 * main_codemap.ml: use of the logger
307 }
d5aa6a98 » aryx
2012-11-19 integrate compiler-libs and CEs
308 `perl -p -i -e 's#Not_found[0-9]#Not_found#' globals/config_pfff.ml`;
8ea4af48 » aryx
2012-02-14 * configure: fix
309
016f9c48 » aryx
2012-06-14 * configure: better error message. Exit earlier.
310 if($error || $error2) {
64b2ffa2 » Yoann Padioleau
2012-02-25 misc
311 pr2 "!!Problems during ./configure!!";
312 }
313
8634b74a » pad
2010-09-22 initial import into fresh git repo.
314 ######################################################################
6dbcc033 » aryx
2013-11-13 * configure: cleanup
315 # Diagnostic
8634b74a » pad
2010-09-22 initial import into fresh git repo.
316 ######################################################################
317
6dbcc033 » aryx
2013-11-13 * configure: cleanup
318 if($error2) {
319 show_missing_package_error_msg($error2);
320 } else {
321 pr2 "All seems fine for $project.";
322 }
323
324 pr2 "
325 To compile $project type:
326 \$ $MAKE_PROGRAM depend
327 \$ $MAKE_PROGRAM
328
329 Then, to test $project simply type:
330 \$ $projectcmdline
331
332 If you want to use the analysis framework and code visualization tools
333 see install.txt or type ./configure --help
334 ";
335
336
337
338 ######################################################################
339 # Documentation
340 ######################################################################
8634b74a » pad
2010-09-22 initial import into fresh git repo.
341
342 __END__
343
344 =head1 NAME
345
346 configure - setting compilation options for pfff
347
348 =head1 SYNOPSIS
349
350 configure [options] [--prefix=/path/to/install]
351
352 Options are:
353 --prefix
354 --[no]visual
0a5c8e53 » aryx
2014-03-04 make lang_bytecode/ optional in configure; also cleanup stuff
355 --[no]bytecode
07114ba3 » aryx
2014-03-04 * configure: new option --nocmt
356 --[no]cmt
8634b74a » pad
2010-09-22 initial import into fresh git repo.
357 --with-all
358 --facebook
359
360 =head1 OPTIONS
361
362 =over 8
363
364
365 =item B<-help>
366
367 Print a brief help message and exits.
368
369 =item B<-man>
370
371 Prints the manual page and exits.
372
373 =back
374
375 =head1 DESCRIPTION
376
377 B<This program> will read command line options and generate
378 a B<Makefile.config> and other files to set the compilation
379 environment for pfff.
380
381 =cut
Something went wrong with that request. Please try again.