ExtUtils-MakeMaker-BigHelper
view release on metacpan or search on metacpan
lib/ExtUtils/MakeMaker/BigHelper.pm view on Meta::CPAN
This handles building multiple .xs files into .so.
=cut
sub dynamic_lib {
my($self, %attribs) = @_;
return $self->MM::dynamic_lib(%attribs) unless $self->{MY_XS_TARGETS};
print STDERR "debug: my dynamic_lib, ", join(',', sort keys %{ $self->{MY_XS_TARGETS} }), "\n" if $debugf;
return '' unless $self->needs_linking(); #might be because of a subdir
return '' unless $self->has_link_code;
my(@m);
my($otherldflags) = $attribs{OTHERLDFLAGS} || "";
my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
my($ldfrom) = '$(LDFROM)';
$armaybe = 'ar' if ($Is{OSF} and $armaybe eq ':');
my $ld_opt = $Is{OS2} ? '$(OPTIMIZE) ' : ''; # Useful on other systems too?
my $ld_fix = $Is{OS2} ? '|| ( $(RM_F) $@ && sh -c false )' : '';
push(@m,'
# This section creates the dynamically loadable $(INST_DYNAMIC)
# from $(OBJECT) and possibly $(MYEXTLIB).
ARMAYBE = '.$armaybe.'
OTHERLDFLAGS = '.$ld_opt.$otherldflags.'
INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
INST_DYNAMIC_FIX = '.$ld_fix.'
');
while (my ($xs, $place) = each %{ $self->{MY_XS_TARGETS} }) {
$place =~ s/::/\//g;
(my $basename = $place) =~ s/^.*\///;
(my $object = $xs) =~ s/\..*?$/.o/;
(my $bootstrap = $xs) =~ s/\..*?$/.bs/;
my $INST_ARCHAUTODIR = $self->catdir('$(INST_ARCHLIB)', 'auto', $place);
my $target = $self->catdir($INST_ARCHAUTODIR, $basename.'.$(DLEXT)');
my $exists = $self->catdir($INST_ARCHAUTODIR, '.exists');
push(@m,'
'.$target.': '.$object.' $(MYEXTLIB) '.$bootstrap.' '.$exists.' $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
');
if ($armaybe ne ':') {
$ldfrom = 'tmp$(LIB_EXT)';
push(@m,' $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
push(@m,' $(RANLIB) '."$ldfrom\n");
}
$ldfrom = "-all $ldfrom -none" if $Is{OSF};
# The IRIX linker doesn't use LD_RUN_PATH
my $ldrun = $Is{IRIX} && $self->{LD_RUN_PATH} ? '-rpath "'.$self->{LD_RUN_PATH}.'"' : '';
# For example in AIX the shared objects/libraries from previous builds
# linger quite a while in the shared dynalinker cache even when nobody
# is using them. This is painful if one for instance tries to restart
# a failed build because the link command will fail unnecessarily 'cos
# the shared object/library is 'busy'.
push(@m,' $(RM_F) $@
');
my $libs = '$(LDLOADLIBS)';
if (($Is{NetBSD} || $Is{Interix}) && $Config{'useshrplib'} eq 'true') {
# Use nothing on static perl platforms, and to the flags needed
# to link against the shared libperl library on shared perl
# platforms. We peek at lddlflags to see if we need -Wl,-R
# or -R to add paths to the run-time library search path.
if ($Config{'lddlflags'} =~ /-Wl,-R/) {
$libs .= ' -L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -Wl,-R$(PERL_ARCHLIB)/CORE -lperl';
} elsif ($Config{'lddlflags'} =~ /-R/) {
$libs .= ' -L$(PERL_INC) -R$(INSTALLARCHLIB)/CORE -R$(PERL_ARCHLIB)/CORE -lperl';
}
}
my $ld_run_path_shell = "";
if ($self->{LD_RUN_PATH} ne "") {
$ld_run_path_shell = 'LD_RUN_PATH="$(LD_RUN_PATH)" ';
}
my @extlibs;
push @extlibs, map { "-L$_" } sort keys %{ $self->{MY_EXTENSION_LIBS} };
push @extlibs, map { "-l$_" } @{ $self->{MY_EXTENSION_LIBS_IN_ORDER} };
push @m, sprintf <<'MAKE', $ld_run_path_shell, $ldrun, '$<', join(' ', @extlibs), $libs;
%s$(LD) %s $(LDDLFLAGS) %s $(OTHERLDFLAGS) -o $@ %s \
$(PERL_ARCHIVE) %s $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) \
$(INST_DYNAMIC_FIX)
MAKE
push @m, <<'MAKE';
$(CHMOD) $(PERM_RWX) $@
MAKE
}
return join('',@m);
}
1;
__END__
=head2 EXPORT
None by default. Use the tags :find and :MY to export the useful things.
=head1 SEE ALSO
Mention other useful documentation such as the documentation of
related modules or operating system documentation (such as man pages
in UNIX), or any relevant external documentation such as RFCs or
standards.
If you have a mailing list set up for your module, mention it here.
If you have a web site set up for your module, mention it here.
=head1 AUTHOR
( run in 0.885 second using v1.01-cache-2.11-cpan-39bf76dae61 )