Upgrade to XSLoader 0.10.
[p5sagit/p5-mst-13.2.git] / ext / DynaLoader / DynaLoader_pm.PL
index 85d2bd3..91fa048 100644 (file)
@@ -26,6 +26,10 @@ sub to_string {
 #   
 #  -- added by VKON, 03-10-2004 to separate $^O-specific between OSes
 #     (so that Win32 never checks for $^O eq 'VMS' for example)
+#
+# The $^O tests test both for $^O and for $Config{osname}.
+# The latter is better for some for cross-compilation setups.
+#
 sub expand_os_specific {
     my $s = shift;
     for ($s) {
@@ -36,7 +40,7 @@ sub expand_os_specific {
          if ($expr =~ m[^(.*?)<<\|\$\^O-$op-$os>>(.*?)$]s) {
              # #if;#else;#endif
              my ($if,$el) = ($1,$2);
-             if (($op eq 'eq' and $^O eq $os) || ($op eq 'ne' and $^O ne $os)) {
+             if (($op eq 'eq' and ($^O eq $os || $Config{osname} eq $os)) || ($op eq 'ne' and ($^O ne $os || $Config{osname} ne $os))) {
                  $if
              }
              else {
@@ -45,7 +49,7 @@ sub expand_os_specific {
          }
          else {
              # #if;#endif
-             if (($op eq 'eq' and $^O eq $os) || ($op eq 'ne' and $^O ne $os)) {
+             if (($op eq 'eq' and ($^O eq $os || $Config{osname} eq $os)) || ($op eq 'ne' and ($^O ne $os || $Config{osname} ne $os))) {
                  $expr
              }
              else {
@@ -64,7 +68,7 @@ unlink "DynaLoader.pm" if -f "DynaLoader.pm";
 open OUT, ">DynaLoader.pm" or die $!;
 print OUT <<'EOT';
 
-# Generated from DynaLoader.pm.PL
+# Generated from DynaLoader_pm.PL
 
 package DynaLoader;
 
@@ -80,22 +84,15 @@ package DynaLoader;
 #
 # Tim.Bunce@ig.co.uk, August 1994
 
-use vars qw($VERSION *AUTOLOAD);
-
-$VERSION = '1.06';
+BEGIN {
+    $VERSION = '1.09';
+}
 
 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 
-# if Carp hasn't been loaded in earlier compile time. :-( 
-# 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;
 
@@ -112,14 +109,19 @@ $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug;
 
 sub dl_load_flags { 0x00 }
 
-# ($dl_dlext, $dlsrc)
-#         = @Config::Config{'dlext', 'dlsrc'};
 EOT
 
-$dl_dlext = $Config::Config{'dlext'};
-$dl_so = $Config::Config{'so'};
-print OUT "  (\$dl_dlext, \$dlsrc) = ('$dl_dlext', ",
-          to_string($Config::Config{'dlsrc'}), ")\n;";
+if ($ENV{PERL_BUILD_EXPAND_CONFIG_VARS}) {
+    print OUT "(\$dl_dlext, \$dl_so, \$dlsrc) = (",
+              to_string($Config{'dlext'}), ",",
+              to_string($Config{'so'}), ",",
+              to_string($Config{'dlsrc'}), ")\n;" ;
+}
+else {
+    print OUT <<'EOT';
+($dl_dlext, $dl_so, $dlsrc) = @Config::Config{qw(dlext so dlsrc)};
+EOT
+}
 
 print OUT expand_os_specific(<<'EOT');
 
@@ -313,8 +315,8 @@ sub bootstrap {
     my $modpname = join(<<$^O-eq-MacOS>>':'<<|$^O-eq-MacOS>>'/'<</$^O-eq-MacOS>>,@modparts);
 
     print STDERR "DynaLoader::bootstrap for $module ",
-                      <<$^O-eq-MacOS>> "(:auto:$modpname:$modfname.<<=$dl_dlext>>)\n" 
-                      <<|$^O-eq-MacOS>>"(auto/$modpname/$modfname.<<=$dl_dlext>>)\n"<</$^O-eq-MacOS>>
+                      <<$^O-eq-MacOS>> "(:auto:$modpname:$modfname.$dl_dlext)\n" 
+                      <<|$^O-eq-MacOS>>"(auto/$modpname/$modfname.$dl_dlext)\n"<</$^O-eq-MacOS>>
        if $dl_debug;
 
     foreach (@INC) {
@@ -333,7 +335,7 @@ sub bootstrap {
        next unless -d $dir; # skip over uninteresting directories
        
        # check for common cases to avoid autoload of dl_findfile
-       my $try = <<$^O-eq-MacOS>> "$dir:$modfname.<<=$dl_dlext>>" <<|$^O-eq-MacOS>> "$dir/$modfname.<<=$dl_dlext>>"<</$^O-eq-MacOS>>;
+       my $try = <<$^O-eq-MacOS>> "$dir:$modfname.$dl_dlext" <<|$^O-eq-MacOS>> "$dir/$modfname.$dl_dlext"<</$^O-eq-MacOS>>;
        last if $file = <<$^O-eq-VMS>>($do_expand) ? dl_expandspec($try) : ((-f $try) && $try);
        <<|$^O-eq-VMS>>(-f $try) && $try;
        <</$^O-eq-VMS>>
@@ -495,23 +497,32 @@ sub dl_findfile {
         my(@names, $name);    # what filenames to look for
         if (m:-l: ) {          # convert -lname to appropriate library name
             s/-l//;
-            push(@names,"lib$_.<<=to_string($Config::Config{'so'})>>");
+            push(@names,"lib$_.$dl_so");
             push(@names,"lib$_.a");
         } else {                # Umm, a bare name. Try various alternatives:
             # these should be ordered with the most likely first
-            push(@names,"$_.<<=$dl_dlext>>")    unless m/\.<<=$dl_dlext>>$/o;
-            push(@names,"$_.<<=$dl_so>>")     unless m/\.<<=$dl_so>>$/o;
-            push(@names,"lib$_.<<=$dl_so>>")  unless m:/:;
+            push(@names,"$_.$dl_dlext")    unless m/\.$dl_dlext$/o;
+            push(@names,"$_.$dl_so")     unless m/\.$dl_so$/o;
+            push(@names,"lib$_.$dl_so")  unless m:/:;
             push(@names,"$_.a")          if !m/\.a$/ and $dlsrc eq "dl_dld.xs";
             push(@names, $_);
         }
+       my $dirsep = '/';
+       <<$^O-eq-symbian>>
+       $dirsep = '\\';
+       if ($0 =~ /^([a-z]):/i) {
+           my $drive = $1;
+           @dirs = map { "$drive:$_" } @dirs;
+           @dl_library_path = map { "$drive:$_" } @dl_library_path;
+       }
+       <</$^O-eq-symbian>>
         foreach $dir (@dirs, @dl_library_path) {
             next unless -d $dir;
            <<$^O-eq-VMS>>
             chop($dir = VMS::Filespec::unixpath($dir));
            <</$^O-eq-VMS>>
             foreach $name (@names) {
-               my($file) = "$dir/$name";
+               my($file) = "$dir$dirsep$name";
                 print STDERR " checking in $dir for $name\n" if $dl_debug;
                $file = ($do_expand) ? dl_expandspec($file) : (-f $file && $file);
                #$file = _check_file($file);