# XXX Splitting this out into its own .pm is a temporary solution.
# This kid package is to be used by MakeMaker. It will not work if
# $self is not a Makemaker.
use 5.00503;
# Broken out of MakeMaker from version 4.11
use strict;
use vars qw($VERSION);
use Config;
use Cwd 'cwd';
sub ext {
if ($^O eq 'VMS') { return &_vms_ext; }
elsif($^O eq 'MSWin32') { return &_win32_ext; }
else { return &_unix_os2_ext; }
}
sub _unix_os2_ext {
$verbose ||= 0;
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
}
warn "Potential libraries are '$potential_libs':\n" if $verbose;
# compute $extralibs, $bsloadlibs and $ldloadlibs from
# $potential_libs
# this is a rewrite of Andy Dougherty's extliblist in perl
my(@searchpath); # from "-L/path" entries in $potential_libs
my($found) = 0;
# Handle possible linker path arguments.
my($ptype) = $1;
unless (-d $thislib){
warn "$ptype$thislib ignored, directory does not exist\n"
if $verbose;
next;
}
$rtype = '-Wl,-R';
} elsif ($Config{'lddlflags'} =~ /-R/) {
$rtype = '-R';
}
}
warn "Warning: $ptype$thislib changed to $ptype$pwd/$thislib\n";
}
push(@searchpath, $thislib);
push(@extralibs, "$ptype$thislib");
push(@ldloadlibs, "$rtype$thislib");
next;
}
# Handle possible library arguments.
unless ($thislib =~ s/^-l//){
warn "Unrecognized argument in LIBS ignored: '$thislib'\n";
next;
}
my($found_lib)=0;
# Try to find the full name of the library. We need this to
# determine whether it's a dynamically-loadable library or not.
# This tends to be subject to various os-specific quirks.
# For gcc-2.6.2 on linux (March 1995), DLD can not load
# .sa libraries, with the exception of libm.sa, so we
# deliberately skip them.
if (@fullname =
# Take care that libfoo.so.10 wins against libfoo.so.9.
# Compare two libraries to find the most recent version
# number. E.g. if you have libfoo.so.9.0.7 and
# libfoo.so.10.1, first convert all digits into two
# decimal places. Then we'll add ".00" to the shorter
# strings so that we're comparing strings of equal length
# Thus we'll compare libfoo.so.09.07.00 with
# libfoo.so.10.01.00. Some libraries might have letters
# in the version. We don't know what they mean, but will
# try to skip them gracefully -- we'll set any letter to
# '0'. Finally, sort in reverse so we can take the
# first element.
#TODO: iterate through the directory instead of sorting
$fullname = "$thispth/" .
(sort { my($ma) = $a;
my($mb) = $b;
# Comparison deliberately backwards
} elsif (-f ($fullname="$thispth/$thislib$Config_libext")){
} elsif ($^O eq 'dgux'
# Some of DG's libraries look like misconnected symbolic
# links, but development tools can follow them. (They
# look like this:
#
# libm.a -> elink:${SDE_PATH:-/usr}/sde/\
#
# , the compilation tools expand the environment variables.)
} else {
warn "$thislib not found in $thispth\n" if $verbose;
next;
}
warn "'-l$thislib' found at $fullname\n" if $verbose;
$found++;
$found_lib++;
# Now update library lists
# what do we know about this library...
# include the path to the lib once in the dynamic linker path
# but only if it is a dynamic lib and not in Perl itself
push @ld_run_path, $fullnamedir
!$ld_run_path_seen{$fullnamedir}++;
# Do not add it into the list if it is already linked in
# with the main perl executable.
# We have to special-case the NeXT, because math and ndbm
# are both in libsys_s
unless ($in_perl ||
push(@extralibs, "-l$thislib");
}
# We might be able to load this archive file dynamically
{
# We push -l$thislib instead of $fullname because
# it avoids hardwiring a fixed path into the .bs file.
# Mkbootstrap will automatically add dl_findfile() to
# the .bs file if it sees a name in the -l format.
# USE THIS, when dl_findfile() is fixed:
# push(@bsloadlibs, "-l$thislib");
# OLD USE WAS while checking results against old_extliblist
push(@bsloadlibs, "$fullname");
} else {
if ($is_dyna){
# For SunOS4, do not add in this shared library if
# it is already linked in the main perl executable
push(@ldloadlibs, "-l$thislib")
unless ($in_perl and $^O eq 'sunos');
} else {
push(@ldloadlibs, "-l$thislib");
}
}
last; # found one here so don't bother looking further
}
warn "Note (probably harmless): "
."No library found for -l$thislib\n"
unless $found_lib>0;
}
unless( $found ) {
}
else {
return ("@extralibs", "@bsloadlibs", "@ldloadlibs",
}
}
sub _win32_ext {
require Text::ParseWords;
$verbose ||= 0;
# If user did not supply a list, we punt.
# (caller should probably use the list in $Config{libs})
# If Config.pm defines a set of default libs, we always
# tack them on to the user-supplied list, unless the user
# specified :nodefault
$potential_libs .= $libs;
}
warn "Potential libraries are '$potential_libs':\n" if $verbose;
# normalize to forward slashes
$libpth =~ s,\\,/,g;
$potential_libs =~ s,\\,/,g;
# compute $extralibs from $potential_libs
my @searchpath; # from "-L/path" in $potential_libs
my @extralibs;
my $lib = '';
my $found = 0;
my $search = 1;
# add "$Config{installarchlib}/CORE" to default search path
push @libpath, "$Config{installarchlib}/CORE";
}
$thislib = $_;
# see if entry is a flag
if (/^:\w+$/) {
warn "Ignoring unknown flag '$thislib'\n"
next;
}
# if searching is disabled, do compiler-specific translations
unless ($search) {
s/^-l(.+)$/$1.lib/ unless $GC;
push(@extralibs, $_);
$found++;
next;
}
# handle possible linker path arguments
if (s/^-L// and not -d) {
warn "$thislib ignored, directory does not exist\n"
if $verbose;
next;
}
elsif (-d) {
warn "Warning: '$thislib' changed to '-L$pwd/$_'\n";
}
push(@searchpath, $_);
next;
}
# handle possible library arguments
if (s/^-l// and $GC and !/^lib/i) {
$_ = "lib$_";
}
my $secondpass = 0;
# look for the file itself
if (-f) {
warn "'$thislib' found as '$_'\n" if $verbose;
$found++;
push(@extralibs, $_);
next;
}
my $found_lib = 0;
unless (-f ($fullname="$thispth\\$_")) {
warn "'$thislib' not found as '$fullname'\n" if $verbose;
next;
}
warn "'$thislib' found as '$fullname'\n" if $verbose;
$found++;
$found_lib++;
last;
}
# do another pass with (or without) leading 'lib' if they used -l
if ($GC) {
goto LOOKAGAIN if s/^lib//i;
}
elsif (!/^lib/i) {
$_ = "lib$_";
goto LOOKAGAIN;
}
}
# give up
warn "Note (probably harmless): "
."No library found for $thislib\n"
unless $found_lib>0;
}
# make sure paths with spaces are properly quoted
# normalize back to backward slashes (to help braindead tools)
# XXX this may break equally braindead GNU tools that don't understand
# backslashes, either. Seems like one can't win here. Cursed be CP/M.
$lib =~ s,/,\\,g;
warn "Result: $lib\n" if $verbose;
}
sub _vms_ext {
$verbose ||= 0;
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
# a library spec could be resolved via a logical name, we go to some trouble
# to insure that the copy in the local tree is used, rather than one to
# which a system-wide logical may point.
}
}
}
unless ($potential_libs) {
warn "Result:\n\tEXTRALIBS: \n\tLDLOADLIBS: $crtlstr\n" if $verbose;
}
# List of common Unix library names and their VMS equivalents
# (VMS equivalent of '' indicates that the library is automatically
# searched by the linker, and should be skipped here.)
'malloc' => '', 'crypt' => '', 'resolv' => '', 'c_s' => '',
'socket' => '', 'X11' => 'DECW$XLIBSHR',
'Xt' => 'DECW$XTSHR', 'Xm' => 'DECW$XMLIBSHR',
'Xmu' => 'DECW$XMULIBSHR');
warn "Potential libraries are '$potential_libs'\n" if $verbose;
# First, sort out directories and library names in the input
}
# Now make sure we've got VMS-syntax absolute directory specs
# (We don't, however, check whether someone's hidden a relative
# path in a logical name.)
unless (-d $dir) {
$dir = '';
next;
}
warn "Resolving directory $dir\n" if $verbose;
}
else {
}
}
}
my($ctype) = '';
# If we don't have a file type, consider it a possibly abbreviated name and
# check for common variants. We try these first to grab libraries before
# a like-named executable image (e.g. -lperl resolves to perlshr.exe
# before perl.exe).
if ($lib !~ /\.[^:>\]]*$/) {
}
warn "Looking for $lib\n" if $verbose;
my($type);
$name = "$dir$variant";
# It's got its own suffix, so we'll have to figure out the type
warn "Note (probably harmless): "
."Plain object file $fullname found in library list\n";
$type = 'OBJ';
}
else {
warn "Note (probably harmless): "
."Unknown library type for $fullname; assuming shared\n";
$type = 'SHR';
}
}
$type = 'SHR';
}
elsif (not length($ctype) and # If we've got a lib already,
# don't bother
$type = 'OLB';
}
elsif (not length($ctype) and # If we've got a lib already,
# don't bother
warn "Note (probably harmless): "
."Plain object file $fullname found in library list\n";
$type = 'OBJ';
}
if (defined $type) {
last if $ctype eq 'SHR';
}
}
if ($ctype) {
# This has to precede any other CRTLs, so just make it first
warn "\tFound as $cand (really $fullname), type $ctype\n"
if $verbose > 1;
next LIB;
}
}
warn "Note (probably harmless): "
."No library found for $lib\n";
}
warn "Result:\n\tEXTRALIBS: $lib\n\tLDLOADLIBS: $ldlib\n" if $verbose;
}
1;