1 # Copyright (C) 2005-2007, Parrot Foundation.
6 config/inter/libparrot.pm - Determines build information for libparrot
10 libparrot is the library containing the parrot VM. This configuration
11 step determines whether it should be build static or shared.
15 package inter
::libparrot
;
20 use base
qw(Parrot::Configure::Step);
23 use Parrot
::Configure
::Utils
':inter';
29 $data{description
} = q{Should parrot link against a shared library};
35 my ( $self, $conf ) = @_;
36 my $parrot_is_shared = $conf->options->get('parrot_is_shared');
37 my $disable_rpath = $conf->options->get('disable-rpath');
39 $parrot_is_shared = integrate
(
40 $conf->data->get('parrot_is_shared'),
44 $parrot_is_shared = 0 unless $conf->data->get('has_dynamic_linking');
46 # Parrot can't necessarily handle a pre-existing installed shared
47 # libparrot.so. At this point, we don't know the actual name
48 # of the shared parrot library. So we try some candidates.
49 # See RT #52288: the check for old_versions should be improved
50 my @libs = ('libparrot.so');
51 my @libpaths = ('/usr/local/lib', '/usr/lib', $conf->data->get('libdir'));
52 if ($^O
eq 'MSWin32') {
53 push @libpaths, (split /;/, $ENV{PATH
});
54 @libs = ('libparrot.dll', 'libparrot.lib', 'libparrot.dll.a');
56 if ($^O
eq 'cygwin') {
57 @libs = ('libparrot.dll.a');
60 @libs = qw
/libparrot.dylib libparrot.a/;
62 if (defined $ENV{LD_LIBRARY_PATH
}) {
63 push @libpaths, (split /:/, $ENV{LD_LIBRARY_PATH
});
65 if (defined $ENV{LD_RUN_PATH
}) {
66 push @libpaths, (split /:/, $ENV{LD_RUN_PATH
});
68 if (defined $ENV{DYLD_LIBRARY_PATH
}) {
69 push @libpaths, (split /:/, $ENV{DYLD_LIBRARY_PATH
});
71 foreach my $f (@libs) {
72 foreach my $d (@libpaths) {
73 my $oldversion = File
::Spec
->catfile($d, $f);
75 warn("\nWarning: Building a shared parrot library may conflict " .
76 "with your previously-installed $oldversion\n");
82 $conf->options->get('ask')
84 $conf->data->get('has_dynamic_linking')
86 $parrot_is_shared = prompt
(
87 "\nShould parrot be built using a shared library?",
88 $parrot_is_shared ?
'y' : 'n'
91 $parrot_is_shared = lc($parrot_is_shared) eq 'y';
95 parrot_is_shared
=> $parrot_is_shared,
97 libparrot_for_makefile_only
=> $parrot_is_shared
98 ?
'$(LIBPARROT_SHARED)'
99 : '$(LIBPARROT_STATIC)',
102 # Set -rpath (or equivalent) for executables to find the
103 # shared libparrot in the build directory.
104 $conf->data->set( rpath_blib
=> ( ! $disable_rpath
106 && $conf->data->get('rpath') )
107 ?
$conf->data->get('rpath')
108 . $conf->data->get('build_dir')
109 . $conf->data->get('slash')
110 . $conf->data->get('blib_dir')
114 # Set -rpath (or equivalent) for the installed executables to find the
115 # installed shared libparrot.
116 $conf->data->set( rpath_lib
=> ( ! $disable_rpath
118 && $conf->data->get('rpath') )
119 ?
$conf->data->get('rpath')
120 . $conf->data->get('libdir')
124 # When building shared libraries and dynamically loadable
125 # modules with 'ld', do we need to include -lparrot? If so
126 # this variable contains the necessary flags. (This is normally
127 # empty, but may be overridden by various hints files for
128 # specific platforms.)
130 # This version works in the build directory.
131 unless ( defined( $conf->data->get('libparrot_ldflags') ) ) {
132 $conf->data->set(libparrot_ldflags
=> '');
135 # This version refers to the installed library.
136 unless ( defined( $conf->data->get('inst_libparrot_ldflags') ) ) {
137 $conf->data->set(inst_libparrot_ldflags
=> '');
140 # When linking an executable to -lparrot, this variable
141 # contains the necessary flags to find and use -lparrot.
143 # This version uses the -lparrot in the build directory.
144 unless ( defined( $conf->data->get('libparrot_linkflags') ) ) {
145 $conf->data->set(libparrot_linkflags
=>
147 . $conf->data->get('build_dir')
148 . $conf->data->get('slash')
149 . $conf->data->get('blib_dir')
154 # This version uses the installed -lparrot.
155 unless ( defined( $conf->data->get('inst_libparrot_linkflags') ) ) {
156 $conf->data->set(inst_libparrot_linkflags
=>
158 . $conf->data->get('libdir')
163 $self->set_result( $parrot_is_shared ?
'yes' : 'no' );
172 # cperl-indent-level: 4
175 # vim: expandtab shiftwidth=4: