Bump version numbers for modules that have changed since 5.8.3
[p5sagit/p5-mst-13.2.git] / ext / DynaLoader / DynaLoader_pm.PL
index 4bd36a0..e4a1ba8 100644 (file)
@@ -27,11 +27,15 @@ package DynaLoader;
 #
 # Tim.Bunce@ig.co.uk, August 1994
 
-$VERSION = "1.04";     # avoid typo warning
+use vars qw($VERSION *AUTOLOAD);
+
+$VERSION = '1.05';     # avoid typo warning
 
 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 
@@ -39,7 +43,6 @@ require AutoLoader;
 # We'll let those bugs get found on the development track.
 require Carp if $] < 5.00450; 
 
-
 # enable debug/trace messages from DynaLoader perl code
 $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug;
 
@@ -70,11 +73,19 @@ print OUT <<'EOT';
 # (VMS support by Charles Bailey <bailey@HMIVAX.HUMGEN.UPENN.EDU>)
 # See dl_expandspec() for more details. Should be harmless but
 # inefficient to define on systems that don't need it.
-$do_expand = $Is_VMS = $^O eq 'VMS';
+$Is_VMS    = $^O eq 'VMS';
+$do_expand = $Is_VMS;
+$Is_MacOS  = $^O eq 'MacOS';
+
+my $Mac_FS;
+$Mac_FS = eval { require Mac::FileSpec::Unixish } if $Is_MacOS;
 
+@dl_shared_objects  = ();       # shared objects for symbols we have 
 @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
+
+#XSLoader.pm may have added elements before we were required
 #@dl_librefs         = ();       # things we have loaded
 #@dl_modules         = ();       # Modules we have loaded
 
@@ -84,7 +95,7 @@ $do_expand = $Is_VMS = $^O eq 'VMS';
 EOT
 
 my $cfg_dl_library_path = <<'EOT';
-push(@dl_library_path, split(' ', $Config::Config{'libpth'}));
+push(@dl_library_path, split(' ', $Config::Config{libpth}));
 EOT
 
 sub dquoted_comma_list {
@@ -96,7 +107,7 @@ if ($ENV{PERL_BUILD_EXPAND_CONFIG_VARS}) {
     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.
+# The below \@dl_library_path has been expanded (%Config) in Perl build time.
 
 \@dl_library_path = ($dl_library_path);
 
@@ -113,18 +124,39 @@ $cfg_dl_library_path
 EOT
 }
 
+my $ldlibpthname;
+my $ldlibpthname_defined;
+my $pthsep;
+
+if ($ENV{PERL_BUILD_EXPAND_CONFIG_VARS}) {
+    $ldlibpthname         = $Config::Config{ldlibpthname};
+    $ldlibpthname_defined = defined $Config::Config{ldlibpthname} ? 1 : 0;
+    $pthsep               = $Config::Config{path_sep};
+}
+else {
+    $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 \$ldlibpthname_defined = $ldlibpthname_defined;
+my \$pthsep               = $pthsep;
+
+EOT
+}
+
 my $env_dl_library_path = <<'EOT';
-if (exists  $Config::Config{ldlibpthname}        &&
-           $Config::Config{ldlibpthname}  ne '' &&
-    exists $ENV{$Config::Config{ldlibpthname}}) {
-    my $ldlibpthname = $Config::Config{ldlibpthname};
-    my $ldlibpth     = $ENV{$ldlibpthname};
-    my $pthsep       = $Config{path_sep};
-    push(@dl_library_path, split(/$pthsep/, $ldlibpth));
+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
 
@@ -144,7 +176,8 @@ 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.
+# The below \@dl_library_path has been expanded (%Config, %ENV)
+# in Perl build time.
 
 \@dl_library_path = ($dl_library_path);
 
@@ -197,6 +230,15 @@ sub bootstrap {
        "  dynamic loading or has the $module module statically linked into it.)\n")
        unless defined(&dl_load_file);
 
+EOT
+
+print OUT <<'EOT' if $^O eq 'os2';
+    # Can dynaload, but cannot dynaload Perl modules...
+    die 'Dynaloaded Perl modules are not available in this build of Perl' if $OS2::is_static;
+
+EOT
+
+print OUT <<'EOT';
     my @modparts = split(/::/,$module);
     my $modfname = $modparts[-1];
 
@@ -205,6 +247,11 @@ sub bootstrap {
     # It may also edit @modparts if required.
     $modfname = &mod2fname(\@modparts) if defined &mod2fname;
 
+    # Truncate the module name to 8.3 format for NetWare
+       if (($^O eq 'NetWare') && (length($modfname) > 8)) {
+               $modfname = substr($modfname, 0, 8);
+       }
+
     my $modpname = join(($Is_MacOS ? ':' : '/'),@modparts);
 
     print STDERR "DynaLoader::bootstrap for $module ",
@@ -217,17 +264,22 @@ sub bootstrap {
        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
-
+       
        # 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);
-
+       last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && $try);
+       
        # no luck here, save dir for possible later dl_findfile search
        push @dirs, $dir;
     }
@@ -237,7 +289,7 @@ sub bootstrap {
     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);
@@ -253,6 +305,14 @@ sub bootstrap {
         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
@@ -271,14 +331,18 @@ sub bootstrap {
        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
+
+       push(@dl_shared_objects, $file); # record files loaded
+
     &$xs(@args);
 }
 
@@ -365,7 +429,7 @@ print OUT <<'EOT';
         #  (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; }
 
@@ -450,8 +514,6 @@ sub dl_find_symbol_anywhere
 
 DynaLoader - Dynamically load C libraries into Perl code
 
-dl_error(), dl_findfile(), dl_expandspec(), dl_load_file(), dl_unload_file(), dl_find_symbol(), dl_find_symbol_anywhere(), dl_undef_symbols(), dl_install_xsub(), dl_load_flags(), bootstrap() - routines used by DynaLoader modules
-
 =head1 SYNOPSIS
 
     package YourPackage;
@@ -485,7 +547,9 @@ useless for accessing non-Perl libraries because it provides almost no
 Perl-to-C 'glue'.  There is, for example, no mechanism for calling a C
 library function or supplying arguments.  A C::DynaLib module
 is available from CPAN sites which performs that function for some
-common system types.
+common system types.  And since the year 2000, there's also Inline::C,
+a module that allows you to write Perl subroutines in C.  Also available
+from your local CPAN site.
 
 DynaLoader Interface Summary
 
@@ -495,6 +559,7 @@ DynaLoader Interface Summary
   $dl_debug
   @dl_librefs
   @dl_modules
+  @dl_shared_objects
                                                   Implemented in:
   bootstrap($modulename)                               Perl
   @filepaths = dl_findfile(@names)                     Perl
@@ -570,6 +635,10 @@ the loaded files.
 
 An array of module (package) names that have been bootstrap'ed.
 
+=item @dl_shared_objects
+
+An array of file names for the shared objects that were loaded.
+
 =item dl_error()
 
 Syntax:
@@ -716,11 +785,11 @@ Apache and mod_perl built with the APXS mechanism.
 Linux, and is a common choice when providing a "wrapper" on other
 mechanisms as is done in the OS/2 port.)
 
-=item dl_loadflags()
+=item dl_load_flags()
 
 Syntax:
 
-    $flags = dl_loadflags $modulename;
+    $flags = dl_load_flags $modulename;
 
 Designed to be a method call, and to be overridden by a derived class
 (i.e. a class which has DynaLoader in its @ISA).  The definition in