This repository has been archived by the owner on Dec 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathConfigure.pl
188 lines (147 loc) · 5.32 KB
/
Configure.pl
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
=head1 NAME
Configure.pl - a configure script for Blizkost
=head1 SYNOPSIS
perl Configure.pl --help
perl Configure.pl
perl Configure.pl --parrot-config=<path_to_parrot_config>
perl Configure.pl --gen-parrot [ -- --options-for-configure-parrot ]
=cut
# Ideally we'd support back further, but fixing the macro framework back
# in time is not a priority
use 5.010;
use strict;
use warnings;
use Config;
my %Perlconfig = %Config;
use Getopt::Long qw(:config auto_help);
use ExtUtils::Embed;
our ( $opt_parrot_config, $opt_gen_parrot);
GetOptions( 'parrot-config=s', 'gen-parrot' );
print <<HELLO;
Hello, I'm Configure. My job is to poke and prod your system to figure out
how to build Blizkost.
HELLO
# Update/generate parrot build if needed
if ($opt_gen_parrot) {
system($^X, 'build/gen_parrot.pl', @ARGV);
}
# Get a list of parrot-configs to invoke.
my @parrot_config_exe = $opt_parrot_config
? ( $opt_parrot_config )
: (
'parrot/parrot_config',
'../../parrot_config',
'parrot_config',
);
# Get configuration information from parrot_config
my %config = read_parrot_config(@parrot_config_exe);
unless (%config) {
die "Unable to locate parrot_config\n"
."Please give me the path to it with the --parrot-config=... option.";
}
my $caution = 0;
sub dubious {
my ($bool, $msg) = @_;
if ($bool) {
print "* * * CONFIGURE HAS DETECTED A POTENTIAL PROBLEM\n";
print $msg;
print "\n";
$caution ||= 1;
}
}
$config{p5_ldopts} = ldopts(1);
$config{p5_ccopts} = ccopts(1);
$config{p5_perl} = $^X;
$config{cc_hasjit} //= '';
# Create the Makefile using the information we just got
create_makefile('Makefile' => %config);
sub read_parrot_config {
my @parrot_config_exe = @_;
my %config = ();
for my $exe (@parrot_config_exe) {
no warnings;
if (open my $PARROT_CONFIG, '-|', "$exe --dump") {
print "Reading configuration information from $exe\n";
while (<$PARROT_CONFIG>) {
$config{$1} = $2 if (/(\w+) => '(.*)'/);
}
close $PARROT_CONFIG;
last if %config;
}
}
%config;
}
# Generate a Makefile from a configuration
sub create_makefile {
my ($name, %config) = @_;
my $maketext = slurp( "build/$name.in" );
$config{'win32_libparrot_copy'} = $^O eq 'MSWin32' ? 'copy $(PARROT_BIN_DIR)\libparrot.dll .' : '';
$maketext =~ s{#IF\((\w+)\):(.*\n)}{$config{osname} eq $1 ? $2 : ""}eg;
$maketext =~ s/@(\w+)@/exists $config{$1} ? $config{$1} : die("No such config var $1")/eg;
if ($^O eq 'MSWin32') {
$maketext =~ s{/}{\\}g;
$maketext =~ s{\\\*}{\\\\*}g;
$maketext =~ s{http:\S+}{ do {my $t = $&; $t =~ s'\\'/'g; $t} }eg;
}
my $outfile = $name;
print "\nCreating $outfile ...\n";
open(my $MAKEOUT, '>', $outfile) ||
die "Unable to write $outfile\n";
print {$MAKEOUT} $maketext;
close $MAKEOUT or die $!;
return;
}
sub slurp {
my $filename = shift;
open my $fh, '<', $filename or die "Unable to read $filename\n";
local $/ = undef;
my $maketext = <$fh>;
close $fh or die $!;
return $maketext;
}
dubious !$Perlconfig{usemultiplicity}, <<MULT;
Your Perl is not configured to allow runtime creation of new interpreters.
Chances of success are quite slim. You should recompile Perl with the
-Dusemultiplicity configuration option (-Dusethreads implies this).
MULT
dubious $Perlconfig{useshrplib} eq 'false', <<SHR;
Your Perl is not built as a dynamic library. In the best case this will result
in a bloated Blizkost library; other possible results include significantly
slower startup, increased per-process memory usage, and in the worst case
crashes, depending on platform, as using non-dynamic libraries from dynamic
ones is rarely well supported. If this is a problem in your environment,
reconfigure Perl with -Duseshrplib.
SHR
# cygwin perl uses the gcc alias, but is gcc-4. cygwin parrot uses gcc-4.
$Perlconfig{cc} = 'gcc-4' if $Perlconfig{cc} eq 'gcc'
and $^O eq 'cygwin'
and $Perlconfig{gccversion} eq '4.3.4 20090804 (release) 1';
dubious $Perlconfig{cc} ne $config{cc}, <<TWOCC;
Blizkost needs to be built using the same version of the same C compiler as
both Perl and Parrot, in order to have a compatible interpretation of runtime
data layouts. However, this is not possible, as your Perl and your Parrot are
built with different C compilers (Perl: $Perlconfig{cc}, Parrot: $config{cc})!
Runtime instabilities are the most likely result. To fix, recompile Parrot or
Perl with the other's compiler.
TWOCC
# XXX: Find a good way to test CPU types, for multiarch systems (it's rarely
# possible to dlopen code for a different CPU, even if both CPU types can be
# interpreted by the hardware)
my $make = $config{make};
print <<BYE;
Okay, we're done!
You can now use `$make' to build your Blizkost library, or '$make blizkost' to
build the binary. After that, you can use `$make test' to run the test suite.
Happy Hacking,
The Blizkost Team
BYE
if ($caution) {
print "\n* * * Proceed with installation at your own risk.\n";
exit 1;
}
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: