require AutoLoader;
*AUTOLOAD = \&AutoLoader::AUTOLOAD;
+use Config;
+
# The following require can't be removed during maintenance
# releases, sadly, because of the risk of buggy code that does
# require Carp; Carp::croak "..."; without brackets dying
# = @Config::Config{'dlext', 'dlsrc'};
EOT
-
-if (!$ENV{PERL_BUILD_EXPAND_CONFIG_VARS}) {
- print OUT <<EOT;
-use Config;
-
-EOT
-}
-
print OUT " (\$dl_dlext, \$dlsrc) = (",
to_string($Config::Config{'dlext'}), ",",
to_string($Config::Config{'dlsrc'}), ")\n;" ;
$do_expand = $Is_VMS;
$Is_MacOS = $^O eq 'MacOS';
+my $Mac_FS;
+$Mac_FS = eval { require Mac::FileSpec::Unixish } if $Is_MacOS;
+
@dl_require_symbols = (); # names of symbols we need
@dl_resolve_using = (); # names of files to link with
@dl_library_path = (); # path to look for files
-@dl_librefs = (); # things we have loaded
-@dl_modules = (); # Modules we have loaded
+
+#XSLoader.pm may have added elements before we were required
+#@dl_librefs = (); # things we have loaded
+#@dl_modules = (); # Modules we have loaded
# This is a fix to support DLD's unfortunate desire to relink -lc
@dl_resolve_using = dl_findfile('-lc') if $dlsrc eq "dl_dld.xs";
if (!$ENV{PERL_BUILD_EXPAND_ENV_VARS}) {
my $dl_library_path = dquoted_comma_list(@dl_library_path);
print OUT <<EOT;
-# This list has been expanded in Perl build time.
-# (%Config expanded, %ENV not)
+# The below \@dl_library_path has been expanded (%Config) in Perl build time.
\@dl_library_path = ($dl_library_path);
}
my $ldlibpthname;
+my $ldlibpthname_defined;
my $pthsep;
if ($ENV{PERL_BUILD_EXPAND_CONFIG_VARS}) {
- $ldlibpthname = qq('$Config::Config{ldlibpthname}');
- $pthsep = qq('$Config::Config{path_sep}');
+ $ldlibpthname = $Config::Config{ldlibpthname};
+ $ldlibpthname_defined = defined $Config::Config{ldlibpthname} ? 1 : 0;
+ $pthsep = $Config::Config{path_sep};
}
else {
- $ldlibpthname = q($Config::Config{ldlibpthname});
- $pthsep = q($Config::Config{path_sep});
+ $ldlibpthname = q($Config::Config{ldlibpthname});
+ $ldlibpthname_defined = q(defined $Config::Config{ldlibpthname});
+ $pthsep = q($Config::Config{path_sep});
print OUT <<EOT;
-my \$ldlibpthname = $ldlibpthname;
-my \$pthsep = $pthsep;
+my \$ldlibpthname = $ldlibpthname;
+my \$ldlibpthname_defined = $ldlibpthname_defined;
+my \$pthsep = $pthsep;
EOT
}
-
-my $env_dl_library_path = <<EOT;
-if (exists \$ENV{$ldlibpthname} && \$ENV{$ldlibpthname} ne '') {
- push(\@dl_library_path, split(/\$pthsep/, \$ENV{$ldlibpthname}));
+my $env_dl_library_path = <<'EOT';
+if ($ldlibpthname_defined &&
+ exists $ENV{$ldlibpthname}) {
+ push(@dl_library_path, split(/$pthsep/, $ENV{$ldlibpthname}));
}
# E.g. HP-UX supports both its native SHLIB_PATH *and* LD_LIBRARY_PATH.
-if ($ldlibpthname ne 'LD_LIBRARY_PATH' && exists \$ENV{LD_LIBRARY_PATH}) {
- push(\@dl_library_path, split(/\$pthsep/, \$ENV{LD_LIBRARY_PATH}));
+if ($ldlibpthname_defined &&
+ $ldlibpthname ne 'LD_LIBRARY_PATH' &&
+ exists $ENV{LD_LIBRARY_PATH}) {
+ push(@dl_library_path, split(/$pthsep/, $ENV{LD_LIBRARY_PATH}));
}
EOT
if ($ENV{PERL_BUILD_EXPAND_CONFIG_VARS} && $ENV{PERL_BUILD_EXPAND_ENV_VARS}) {
my $dl_library_path = dquoted_comma_list(@dl_library_path);
print OUT <<EOT;
-# This list has been expanded in Perl build time.
-# (%Config expanded, %ENV expanded)
+# The below \@dl_library_path has been expanded (%Config, %ENV)
+# in Perl build time.
\@dl_library_path = ($dl_library_path);
# It may also edit @modparts if required.
$modfname = &mod2fname(\@modparts) if defined &mod2fname;
+ if (($^O eq 'NetWare') && (length($modfname) > 8)) {
+ $modfname = substr($modfname, 0, 8);
+ }
+
my $modpname = join(($Is_MacOS ? ':' : '/'),@modparts);
print STDERR "DynaLoader::bootstrap for $module ",
chop($_ = VMS::Filespec::unixpath($_)) if $Is_VMS;
my $dir;
if ($Is_MacOS) {
- chop $_ if /:$/;
- $dir = "$_:auto:$modpname";
+ my $path = $_;
+ if ($Mac_FS && ! -d $path) {
+ $path = Mac::FileSpec::Unixish::nativize($path);
+ }
+ $path .= ":" unless /:$/;
+ $dir = "${path}auto:$modpname";
} else {
$dir = "$_/auto/$modpname";
}
- next unless -d $dir; # skip over uninteresting directories
+ if ($^O ne 'NetWare') {
+ next unless -d $dir; # skip over uninteresting directories
+ }
+ else {
+ next if -f $dir; # skip over uninteresting directories
+ }
# check for common cases to avoid autoload of dl_findfile
my $try = $Is_MacOS ? "$dir:$modfname.$dl_dlext" : "$dir/$modfname.$dl_dlext";
- last if $file = ($do_expand) ? dl_expandspec($try) : (-f $try && $try);
+ if ($^O ne 'NetWare') {
+ last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && $try);
+ }
+ elsif (!(-d $try)) {
+ last if $file = ($do_expand) ? dl_expandspec($try) : ($try);
+ }
# no luck here, save dir for possible later dl_findfile search
push @dirs, $dir;
croak("Can't locate loadable object for module $module in \@INC (\@INC contains: @INC)")
unless $file; # wording similar to error from 'require'
- $file = uc($file) if $Is_VMS && $Config{d_vms_case_sensitive_symbols};
+ $file = uc($file) if $Is_VMS && $Config::Config{d_vms_case_sensitive_symbols};
my $bootname = "boot_$module";
$bootname =~ s/\W/_/g;
@dl_require_symbols = ($bootname);
warn "$bs: $@\n" if $@;
}
+ my $boot_symbol_ref;
+
+ if ($^O eq 'darwin') {
+ if ($boot_symbol_ref = dl_find_symbol(0, $bootname)) {
+ goto boot; #extension library has already been loaded, e.g. darwin
+ }
+ }
+
# Many dynamic extension loading problems will appear to come from
# this section of code: XYZ failed at line 123 of DynaLoader.pm.
# Often these errors are actually occurring in the initialisation
Carp::carp("Undefined symbols present after loading $file: @unresolved\n");
}
- my $boot_symbol_ref = dl_find_symbol($libref, $bootname) or
+ $boot_symbol_ref = dl_find_symbol($libref, $bootname) or
croak("Can't find '$bootname' symbol in $file\n");
- my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
-
push(@dl_modules, $module); # record loaded module
+ boot:
+ my $xs = dl_install_xsub("${module}::bootstrap", $boot_symbol_ref, $file);
+
# See comment block above
&$xs(@args);
}
# (this is a more complicated issue than it first appears)
if (m:/: && -d $_) { push(@dirs, $_); next; }
- # VMS: we may be using native VMS directry syntax instead of
+ # VMS: we may be using native VMS directory syntax instead of
# Unix emulation, so check this as well
if ($Is_VMS && /[:>\]]/ && -d $_) { push(@dirs, $_); next; }