/
libparrot.pm
108 lines (83 loc) · 2.69 KB
/
libparrot.pm
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
# Copyright (C) 2005-2007, The Perl Foundation.
# $Id$
=head1 NAME
config/inter/libparrot.pm - Determines build information for libparrot
=head1 DESCRIPTION
libparrot is the library containing the parrot VM. This configuration
step determines whether it should be build static or shared.
=cut
package inter::libparrot;
use strict;
use warnings;
use base qw(Parrot::Configure::Step);
use Parrot::Configure::Utils ':inter';
sub _init {
my $self = shift;
my %data;
$data{description} = q{Should parrot link against a shared library};
$data{result} = q{};
return \%data;
}
sub runstep {
my ( $self, $conf ) = @_;
my $parrot_is_shared = $conf->options->get('parrot_is_shared');
$parrot_is_shared = integrate(
$conf->data->get('parrot_is_shared'),
$parrot_is_shared
);
$parrot_is_shared = 0 unless $conf->data->get('has_dynamic_linking');
# Parrot can't necessarily handle a pre-existing installed shared
# libparrot.so. At this point, we don't know the actual name
# of the shared parrot library. However, 'libparrot.so' will catch
# at least some of the problems.
# RT#52288: the check for old_versions should be improved
my $old_version
= File::Spec->catfile($conf->data->get('libdir'), 'libparrot.so');
if (-e $old_version) {
warn("\nWarning: Building a shared parrot library may conflict " .
"with your previously-installed $old_version\n");
}
if (
$conf->options->get('ask')
&&
$conf->data->get('has_dynamic_linking')
) {
$parrot_is_shared = prompt(
"\nShould parrot be built using a shared library?",
$parrot_is_shared ? 'y' : 'n'
);
$parrot_is_shared = lc($parrot_is_shared) eq 'y';
}
$conf->data->set(
parrot_is_shared => $parrot_is_shared,
libparrot => $parrot_is_shared
? '$(LIBPARROT_SHARED)'
: '$(LIBPARROT_STATIC)',
);
$conf->data->set(
rpath_blib => ( $parrot_is_shared && $conf->data->get('rpath') )
? $conf->data->get('rpath')
. $conf->data->get('build_dir')
. $conf->data->get('slash')
. $conf->data->get('blib_dir')
: ''
);
unless ( defined( $conf->data->get('libparrot_ldflags') ) ) {
$conf->data->set(libparrot_ldflags =>
'-L'
. $conf->data->get('build_dir')
. $conf->data->get('slash')
. $conf->data->get('blib_dir')
. ' -lparrot'
);
}
$self->set_result( $parrot_is_shared ? 'yes' : 'no' );
return 1;
}
1;
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: