home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / interp / perl5.005.tar.gz / perl5.005.tar / perl5.005 / lib / ExtUtils / Liblist.pm < prev    next >
Encoding:
Perl POD Document  |  1998-07-22  |  21.9 KB  |  642 lines

  1. package ExtUtils::Liblist;
  2. use vars qw($VERSION);
  3. # Broken out of MakeMaker from version 4.11
  4.  
  5. $VERSION = substr q$Revision: 1.25 $, 10;
  6.  
  7. use Config;
  8. use Cwd 'cwd';
  9. use File::Basename;
  10.  
  11. sub ext {
  12.   if   ($^O eq 'VMS')     { return &_vms_ext;      }
  13.   elsif($^O eq 'MSWin32') { return &_win32_ext;    }
  14.   else                    { return &_unix_os2_ext; }
  15. }
  16.  
  17. sub _unix_os2_ext {
  18.     my($self,$potential_libs, $verbose) = @_;
  19.     if ($^O =~ 'os2' and $Config{libs}) { 
  20.     # Dynamic libraries are not transitive, so we may need including
  21.     # the libraries linked against perl.dll again.
  22.  
  23.     $potential_libs .= " " if $potential_libs;
  24.     $potential_libs .= $Config{libs};
  25.     }
  26.     return ("", "", "", "") unless $potential_libs;
  27.     warn "Potential libraries are '$potential_libs':\n" if $verbose;
  28.  
  29.     my($so)   = $Config{'so'};
  30.     my($libs) = $Config{'libs'};
  31.     my $Config_libext = $Config{lib_ext} || ".a";
  32.  
  33.  
  34.     # compute $extralibs, $bsloadlibs and $ldloadlibs from
  35.     # $potential_libs
  36.     # this is a rewrite of Andy Dougherty's extliblist in perl
  37.  
  38.     my(@searchpath); # from "-L/path" entries in $potential_libs
  39.     my(@libpath) = split " ", $Config{'libpth'};
  40.     my(@ldloadlibs, @bsloadlibs, @extralibs, @ld_run_path, %ld_run_path_seen);
  41.     my($fullname, $thislib, $thispth, @fullname);
  42.     my($pwd) = cwd(); # from Cwd.pm
  43.     my($found) = 0;
  44.  
  45.     foreach $thislib (split ' ', $potential_libs){
  46.  
  47.     # Handle possible linker path arguments.
  48.     if ($thislib =~ s/^(-[LR])//){    # save path flag type
  49.         my($ptype) = $1;
  50.         unless (-d $thislib){
  51.         warn "$ptype$thislib ignored, directory does not exist\n"
  52.             if $verbose;
  53.         next;
  54.         }
  55.         unless ($self->file_name_is_absolute($thislib)) {
  56.           warn "Warning: $ptype$thislib changed to $ptype$pwd/$thislib\n";
  57.           $thislib = $self->catdir($pwd,$thislib);
  58.         }
  59.         push(@searchpath, $thislib);
  60.         push(@extralibs,  "$ptype$thislib");
  61.         push(@ldloadlibs, "$ptype$thislib");
  62.         next;
  63.     }
  64.  
  65.     # Handle possible library arguments.
  66.     unless ($thislib =~ s/^-l//){
  67.       warn "Unrecognized argument in LIBS ignored: '$thislib'\n";
  68.       next;
  69.     }
  70.  
  71.     my($found_lib)=0;
  72.     foreach $thispth (@searchpath, @libpath){
  73.  
  74.         # Try to find the full name of the library.  We need this to
  75.         # determine whether it's a dynamically-loadable library or not.
  76.         # This tends to be subject to various os-specific quirks.
  77.         # For gcc-2.6.2 on linux (March 1995), DLD can not load
  78.         # .sa libraries, with the exception of libm.sa, so we
  79.         # deliberately skip them.
  80.         if (@fullname =
  81.             $self->lsdir($thispth,"^\Qlib$thislib.$so.\E[0-9]+")){
  82.         # Take care that libfoo.so.10 wins against libfoo.so.9.
  83.         # Compare two libraries to find the most recent version
  84.         # number.  E.g.  if you have libfoo.so.9.0.7 and
  85.         # libfoo.so.10.1, first convert all digits into two
  86.         # decimal places.  Then we'll add ".00" to the shorter
  87.         # strings so that we're comparing strings of equal length
  88.         # Thus we'll compare libfoo.so.09.07.00 with
  89.         # libfoo.so.10.01.00.  Some libraries might have letters
  90.         # in the version.  We don't know what they mean, but will
  91.         # try to skip them gracefully -- we'll set any letter to
  92.         # '0'.  Finally, sort in reverse so we can take the
  93.         # first element.
  94.  
  95.         #TODO: iterate through the directory instead of sorting
  96.  
  97.         $fullname = "$thispth/" .
  98.         (sort { my($ma) = $a;
  99.             my($mb) = $b;
  100.             $ma =~ tr/A-Za-z/0/s;
  101.             $ma =~ s/\b(\d)\b/0$1/g;
  102.             $mb =~ tr/A-Za-z/0/s;
  103.             $mb =~ s/\b(\d)\b/0$1/g;
  104.             while (length($ma) < length($mb)) { $ma .= ".00"; }
  105.             while (length($mb) < length($ma)) { $mb .= ".00"; }
  106.             # Comparison deliberately backwards
  107.             $mb cmp $ma;} @fullname)[0];
  108.         } elsif (-f ($fullname="$thispth/lib$thislib.$so")
  109.          && (($Config{'dlsrc'} ne "dl_dld.xs") || ($thislib eq "m"))){
  110.         } elsif (-f ($fullname="$thispth/lib${thislib}_s$Config_libext")
  111.          && ($thislib .= "_s") ){ # we must explicitly use _s version
  112.         } elsif (-f ($fullname="$thispth/lib$thislib$Config_libext")){
  113.         } elsif (-f ($fullname="$thispth/$thislib$Config_libext")){
  114.         } elsif (-f ($fullname="$thispth/Slib$thislib$Config_libext")){
  115.         } elsif ($^O eq 'dgux'
  116.          && -l ($fullname="$thispth/lib$thislib$Config_libext")
  117.          && readlink($fullname) =~ /^elink:/) {
  118.          # Some of DG's libraries look like misconnected symbolic
  119.          # links, but development tools can follow them.  (They
  120.          # look like this:
  121.          #
  122.          #    libm.a -> elink:${SDE_PATH:-/usr}/sde/\
  123.          #    ${TARGET_BINARY_INTERFACE:-m88kdgux}/usr/lib/libm.a
  124.          #
  125.          # , the compilation tools expand the environment variables.)
  126.         } else {
  127.         warn "$thislib not found in $thispth\n" if $verbose;
  128.         next;
  129.         }
  130.         warn "'-l$thislib' found at $fullname\n" if $verbose;
  131.         my($fullnamedir) = dirname($fullname);
  132.         push @ld_run_path, $fullnamedir unless $ld_run_path_seen{$fullnamedir}++;
  133.         $found++;
  134.         $found_lib++;
  135.  
  136.         # Now update library lists
  137.  
  138.         # what do we know about this library...
  139.         my $is_dyna = ($fullname !~ /\Q$Config_libext\E$/);
  140.         my $in_perl = ($libs =~ /\B-l\Q$ {thislib}\E\b/s);
  141.  
  142.         # Do not add it into the list if it is already linked in
  143.         # with the main perl executable.
  144.         # We have to special-case the NeXT, because math and ndbm 
  145.         # are both in libsys_s
  146.         unless ($in_perl || 
  147.         ($Config{'osname'} eq 'next' &&
  148.             ($thislib eq 'm' || $thislib eq 'ndbm')) ){
  149.         push(@extralibs, "-l$thislib");
  150.         }
  151.  
  152.         # We might be able to load this archive file dynamically
  153.         if ( ($Config{'dlsrc'} =~ /dl_next/ && $Config{'osvers'} lt '4_0')
  154.         ||   ($Config{'dlsrc'} =~ /dl_dld/) )
  155.         {
  156.         # We push -l$thislib instead of $fullname because
  157.         # it avoids hardwiring a fixed path into the .bs file.
  158.         # Mkbootstrap will automatically add dl_findfile() to
  159.         # the .bs file if it sees a name in the -l format.
  160.         # USE THIS, when dl_findfile() is fixed: 
  161.         # push(@bsloadlibs, "-l$thislib");
  162.         # OLD USE WAS while checking results against old_extliblist
  163.         push(@bsloadlibs, "$fullname");
  164.         } else {
  165.         if ($is_dyna){
  166.                     # For SunOS4, do not add in this shared library if
  167.                     # it is already linked in the main perl executable
  168.             push(@ldloadlibs, "-l$thislib")
  169.             unless ($in_perl and $^O eq 'sunos');
  170.         } else {
  171.             push(@ldloadlibs, "-l$thislib");
  172.         }
  173.         }
  174.         last;    # found one here so don't bother looking further
  175.     }
  176.     warn "Note (probably harmless): "
  177.              ."No library found for -l$thislib\n"
  178.         unless $found_lib>0;
  179.     }
  180.     return ('','','','') unless $found;
  181.     ("@extralibs", "@bsloadlibs", "@ldloadlibs",join(":",@ld_run_path));
  182. }
  183.  
  184. sub _win32_ext {
  185.  
  186.     require Text::ParseWords;
  187.  
  188.     my($self, $potential_libs, $verbose) = @_;
  189.  
  190.     # If user did not supply a list, we punt.
  191.     # (caller should probably use the list in $Config{libs})
  192.     return ("", "", "", "") unless $potential_libs;
  193.  
  194.     my($so)   = $Config{'so'};
  195.     my($libs) = $Config{'libs'};
  196.     my($libpth) = $Config{'libpth'};
  197.     my($libext) = $Config{'lib_ext'} || ".lib";
  198.  
  199.     if ($libs and $potential_libs !~ /:nodefault/i) { 
  200.     # If Config.pm defines a set of default libs, we always
  201.     # tack them on to the user-supplied list, unless the user
  202.     # specified :nodefault
  203.  
  204.     $potential_libs .= " " if $potential_libs;
  205.     $potential_libs .= $libs;
  206.     }
  207.     warn "Potential libraries are '$potential_libs':\n" if $verbose;
  208.  
  209.     # normalize to forward slashes
  210.     $libpth =~ s,\\,/,g;
  211.     $potential_libs =~ s,\\,/,g;
  212.  
  213.     # compute $extralibs from $potential_libs
  214.  
  215.     my(@searchpath); # from "-L/path" entries in $potential_libs
  216.     my(@libpath) = Text::ParseWords::quotewords('\s+', 0, $libpth);
  217.     my(@extralibs);
  218.     my($fullname, $thislib, $thispth);
  219.     my($pwd) = cwd(); # from Cwd.pm
  220.     my($lib) = '';
  221.     my($found) = 0;
  222.  
  223.     foreach $thislib (Text::ParseWords::quotewords('\s+', 0, $potential_libs)){
  224.  
  225.     # Handle possible linker path arguments.
  226.     if ($thislib =~ s/^-L// and not -d $thislib) {
  227.         warn "-L$thislib ignored, directory does not exist\n"
  228.         if $verbose;
  229.         next;
  230.     }
  231.     elsif (-d $thislib) {
  232.         unless ($self->file_name_is_absolute($thislib)) {
  233.           warn "Warning: '-L$thislib' changed to '-L$pwd/$thislib'\n";
  234.           $thislib = $self->catdir($pwd,$thislib);
  235.         }
  236.         push(@searchpath, $thislib);
  237.         next;
  238.     }
  239.  
  240.     # Handle possible library arguments.
  241.     if ($thislib =~ s/^-l// and $thislib !~ /^lib/i) {
  242.         $thislib = "lib$thislib";
  243.     }
  244.     $thislib .= $libext if $thislib !~ /\Q$libext\E$/i;
  245.  
  246.         # look for the file itself
  247.     if (-f $thislib) {
  248.         warn "'$thislib' found\n" if $verbose;
  249.         $found++;
  250.         push(@extralibs, $thislib);
  251.         next;
  252.     }
  253.  
  254.     my($found_lib)=0;
  255.     foreach $thispth (@searchpath, @libpath){
  256.         unless (-f ($fullname="$thispth\\$thislib")) {
  257.         warn "$thislib not found in $thispth\n" if $verbose;
  258.         next;
  259.         }
  260.         warn "'$thislib' found at $fullname\n" if $verbose;
  261.         $found++;
  262.         $found_lib++;
  263.         push(@extralibs, $fullname);
  264.         last;
  265.     }
  266.     warn "Note (probably harmless): "
  267.              ."No library found for '$thislib'\n"
  268.         unless $found_lib>0;
  269.     }
  270.     return ('','','','') unless $found;
  271.  
  272.     # make sure paths with spaces are properly quoted
  273.     @extralibs = map { (/\s/ && !/^".*"$/) ? qq["$_"] : $_ } @extralibs;
  274.     $lib = join(' ',@extralibs);
  275.  
  276.     # normalize back to backward slashes (to help braindead tools)
  277.     # XXX this may break equally braindead GNU tools that don't understand
  278.     # backslashes, either.  Seems like one can't win here.  Cursed be CP/M.
  279.     $lib =~ s,/,\\,g;
  280.  
  281.     warn "Result: $lib\n" if $verbose;
  282.     wantarray ? ($lib, '', $lib, '') : $lib;
  283. }
  284.  
  285.  
  286. sub _vms_ext {
  287.   my($self, $potential_libs,$verbose) = @_;
  288.   my(@crtls,$crtlstr);
  289.   my($dbgqual) = $self->{OPTIMIZE} || $Config{'optimize'} ||
  290.                  $self->{CCFLAS}   || $Config{'ccflags'};
  291.   @crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
  292.               . 'PerlShr/Share' );
  293.   push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libs'});
  294.   push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
  295.   # In general, we pass through the basic libraries from %Config unchanged.
  296.   # The one exception is that if we're building in the Perl source tree, and
  297.   # a library spec could be resolved via a logical name, we go to some trouble
  298.   # to insure that the copy in the local tree is used, rather than one to
  299.   # which a system-wide logical may point.
  300.   if ($self->{PERL_SRC}) {
  301.     my($lib,$locspec,$type);
  302.     foreach $lib (@crtls) { 
  303.       if (($locspec,$type) = $lib =~ m-^([\w$\-]+)(/\w+)?- and $locspec =~ /perl/i) {
  304.         if    (lc $type eq '/share')   { $locspec .= $Config{'exe_ext'}; }
  305.         elsif (lc $type eq '/library') { $locspec .= $Config{'lib_ext'}; }
  306.         else                           { $locspec .= $Config{'obj_ext'}; }
  307.         $locspec = $self->catfile($self->{PERL_SRC},$locspec);
  308.         $lib = "$locspec$type" if -e $locspec;
  309.       }
  310.     }
  311.   }
  312.   $crtlstr = @crtls ? join(' ',@crtls) : '';
  313.  
  314.   unless ($potential_libs) {
  315.     warn "Result:\n\tEXTRALIBS: \n\tLDLOADLIBS: $crtlstr\n" if $verbose;
  316.     return ('', '', $crtlstr, '');
  317.   }
  318.  
  319.   my(@dirs,@libs,$dir,$lib,%sh,%olb,%obj,$ldlib);
  320.   my $cwd = cwd();
  321.   my($so,$lib_ext,$obj_ext) = @Config{'so','lib_ext','obj_ext'};
  322.   # List of common Unix library names and there VMS equivalents
  323.   # (VMS equivalent of '' indicates that the library is automatially
  324.   # searched by the linker, and should be skipped here.)
  325.   my %libmap = ( 'm' => '', 'f77' => '', 'F77' => '', 'V77' => '', 'c' => '',
  326.                  'malloc' => '', 'crypt' => '', 'resolv' => '', 'c_s' => '',
  327.                  'socket' => '', 'X11' => 'DECW$XLIBSHR',
  328.                  'Xt' => 'DECW$XTSHR', 'Xm' => 'DECW$XMLIBSHR',
  329.                  'Xmu' => 'DECW$XMULIBSHR');
  330.   if ($Config{'vms_cc_type'} ne 'decc') { $libmap{'curses'} = 'VAXCCURSE'; }
  331.  
  332.   warn "Potential libraries are '$potential_libs'\n" if $verbose;
  333.  
  334.   # First, sort out directories and library names in the input
  335.   foreach $lib (split ' ',$potential_libs) {
  336.     push(@dirs,$1),   next if $lib =~ /^-L(.*)/;
  337.     push(@dirs,$lib), next if $lib =~ /[:>\]]$/;
  338.     push(@dirs,$lib), next if -d $lib;
  339.     push(@libs,$1),   next if $lib =~ /^-l(.*)/;
  340.     push(@libs,$lib);
  341.   }
  342.   push(@dirs,split(' ',$Config{'libpth'}));
  343.  
  344.   # Now make sure we've got VMS-syntax absolute directory specs
  345.   # (We don't, however, check whether someone's hidden a relative
  346.   # path in a logical name.)
  347.   foreach $dir (@dirs) {
  348.     unless (-d $dir) {
  349.       warn "Skipping nonexistent Directory $dir\n" if $verbose > 1;
  350.       $dir = '';
  351.       next;
  352.     }
  353.     warn "Resolving directory $dir\n" if $verbose;
  354.     if ($self->file_name_is_absolute($dir)) { $dir = $self->fixpath($dir,1); }
  355.     else                                    { $dir = $self->catdir($cwd,$dir); }
  356.   }
  357.   @dirs = grep { length($_) } @dirs;
  358.   unshift(@dirs,''); # Check each $lib without additions first
  359.  
  360.   LIB: foreach $lib (@libs) {
  361.     if (exists $libmap{$lib}) {
  362.       next unless length $libmap{$lib};
  363.       $lib = $libmap{$lib};
  364.     }
  365.  
  366.     my(@variants,$variant,$name,$test,$cand);
  367.     my($ctype) = '';
  368.  
  369.     # If we don't have a file type, consider it a possibly abbreviated name and
  370.     # check for common variants.  We try these first to grab libraries before
  371.     # a like-named executable image (e.g. -lperl resolves to perlshr.exe
  372.     # before perl.exe).
  373.     if ($lib !~ /\.[^:>\]]*$/) {
  374.       push(@variants,"${lib}shr","${lib}rtl","${lib}lib");
  375.       push(@variants,"lib$lib") if $lib !~ /[:>\]]/;
  376.     }
  377.     push(@variants,$lib);
  378.     warn "Looking for $lib\n" if $verbose;
  379.     foreach $variant (@variants) {
  380.       foreach $dir (@dirs) {
  381.         my($type);
  382.  
  383.         $name = "$dir$variant";
  384.         warn "\tChecking $name\n" if $verbose > 2;
  385.         if (-f ($test = VMS::Filespec::rmsexpand($name))) {
  386.           # It's got its own suffix, so we'll have to figure out the type
  387.           if    ($test =~ /(?:$so|exe)$/i)      { $type = 'sh'; }
  388.           elsif ($test =~ /(?:$lib_ext|olb)$/i) { $type = 'olb'; }
  389.           elsif ($test =~ /(?:$obj_ext|obj)$/i) {
  390.             warn "Note (probably harmless): "
  391.              ."Plain object file $test found in library list\n";
  392.             $type = 'obj';
  393.           }
  394.           else {
  395.             warn "Note (probably harmless): "
  396.              ."Unknown library type for $test; assuming shared\n";
  397.             $type = 'sh';
  398.           }
  399.         }
  400.         elsif (-f ($test = VMS::Filespec::rmsexpand($name,$so))      or
  401.                -f ($test = VMS::Filespec::rmsexpand($name,'.exe')))     {
  402.           $type = 'sh';
  403.           $name = $test unless $test =~ /exe;?\d*$/i;
  404.         }
  405.         elsif (not length($ctype) and  # If we've got a lib already, don't bother
  406.                ( -f ($test = VMS::Filespec::rmsexpand($name,$lib_ext)) or
  407.                  -f ($test = VMS::Filespec::rmsexpand($name,'.olb'))))  {
  408.           $type = 'olb';
  409.           $name = $test unless $test =~ /olb;?\d*$/i;
  410.         }
  411.         elsif (not length($ctype) and  # If we've got a lib already, don't bother
  412.                ( -f ($test = VMS::Filespec::rmsexpand($name,$obj_ext)) or
  413.                  -f ($test = VMS::Filespec::rmsexpand($name,'.obj'))))  {
  414.           warn "Note (probably harmless): "
  415.                ."Plain object file $test found in library list\n";
  416.           $type = 'obj';
  417.           $name = $test unless $test =~ /obj;?\d*$/i;
  418.         }
  419.         if (defined $type) {
  420.           $ctype = $type; $cand = $name;
  421.           last if $ctype eq 'sh';
  422.         }
  423.       }
  424.       if ($ctype) { 
  425.         eval '$' . $ctype . "{'$cand'}++";
  426.         die "Error recording library: $@" if $@;
  427.         warn "\tFound as $cand (really $test), type $ctype\n" if $verbose > 1;
  428.         next LIB;
  429.       }
  430.     }
  431.     warn "Note (probably harmless): "
  432.          ."No library found for $lib\n";
  433.   }
  434.  
  435.   @libs = sort keys %obj;
  436.   # This has to precede any other CRTLs, so just make it first
  437.   if ($olb{VAXCCURSE}) {
  438.     push(@libs,"$olb{VAXCCURSE}/Library");
  439.     delete $olb{VAXCCURSE};
  440.   }
  441.   push(@libs, map { "$_/Library" } sort keys %olb);
  442.   push(@libs, map { "$_/Share"   } sort keys %sh);
  443.   $lib = join(' ',@libs);
  444.  
  445.   $ldlib = $crtlstr ? "$lib $crtlstr" : $lib;
  446.   warn "Result:\n\tEXTRALIBS: $lib\n\tLDLOADLIBS: $ldlib\n" if $verbose;
  447.   wantarray ? ($lib, '', $ldlib, '') : $lib;
  448. }
  449.  
  450. 1;
  451.  
  452. __END__
  453.  
  454. =head1 NAME
  455.  
  456. ExtUtils::Liblist - determine libraries to use and how to use them
  457.  
  458. =head1 SYNOPSIS
  459.  
  460. C<require ExtUtils::Liblist;>
  461.  
  462. C<ExtUtils::Liblist::ext($self, $potential_libs, $verbose);>
  463.  
  464. =head1 DESCRIPTION
  465.  
  466. This utility takes a list of libraries in the form C<-llib1 -llib2
  467. -llib3> and prints out lines suitable for inclusion in an extension
  468. Makefile.  Extra library paths may be included with the form
  469. C<-L/another/path> this will affect the searches for all subsequent
  470. libraries.
  471.  
  472. It returns an array of four scalar values: EXTRALIBS, BSLOADLIBS,
  473. LDLOADLIBS, and LD_RUN_PATH.  Some of these don't mean anything
  474. on VMS and Win32.  See the details about those platform specifics
  475. below.
  476.  
  477. Dependent libraries can be linked in one of three ways:
  478.  
  479. =over 2
  480.  
  481. =item * For static extensions
  482.  
  483. by the ld command when the perl binary is linked with the extension
  484. library. See EXTRALIBS below.
  485.  
  486. =item * For dynamic extensions
  487.  
  488. by the ld command when the shared object is built/linked. See
  489. LDLOADLIBS below.
  490.  
  491. =item * For dynamic extensions
  492.  
  493. by the DynaLoader when the shared object is loaded. See BSLOADLIBS
  494. below.
  495.  
  496. =back
  497.  
  498. =head2 EXTRALIBS
  499.  
  500. List of libraries that need to be linked with when linking a perl
  501. binary which includes this extension Only those libraries that
  502. actually exist are included.  These are written to a file and used
  503. when linking perl.
  504.  
  505. =head2 LDLOADLIBS and LD_RUN_PATH
  506.  
  507. List of those libraries which can or must be linked into the shared
  508. library when created using ld. These may be static or dynamic
  509. libraries.  LD_RUN_PATH is a colon separated list of the directories
  510. in LDLOADLIBS. It is passed as an environment variable to the process
  511. that links the shared library.
  512.  
  513. =head2 BSLOADLIBS
  514.  
  515. List of those libraries that are needed but can be linked in
  516. dynamically at run time on this platform.  SunOS/Solaris does not need
  517. this because ld records the information (from LDLOADLIBS) into the
  518. object file.  This list is used to create a .bs (bootstrap) file.
  519.  
  520. =head1 PORTABILITY
  521.  
  522. This module deals with a lot of system dependencies and has quite a
  523. few architecture specific B<if>s in the code.
  524.  
  525. =head2 VMS implementation
  526.  
  527. The version of ext() which is executed under VMS differs from the
  528. Unix-OS/2 version in several respects:
  529.  
  530. =over 2
  531.  
  532. =item *
  533.  
  534. Input library and path specifications are accepted with or without the
  535. C<-l> and C<-L> prefices used by Unix linkers.  If neither prefix is
  536. present, a token is considered a directory to search if it is in fact
  537. a directory, and a library to search for otherwise.  Authors who wish
  538. their extensions to be portable to Unix or OS/2 should use the Unix
  539. prefixes, since the Unix-OS/2 version of ext() requires them.
  540.  
  541. =item *
  542.  
  543. Wherever possible, shareable images are preferred to object libraries,
  544. and object libraries to plain object files.  In accordance with VMS
  545. naming conventions, ext() looks for files named I<lib>shr and I<lib>rtl;
  546. it also looks for I<lib>lib and libI<lib> to accomodate Unix conventions
  547. used in some ported software.
  548.  
  549. =item *
  550.  
  551. For each library that is found, an appropriate directive for a linker options
  552. file is generated.  The return values are space-separated strings of
  553. these directives, rather than elements used on the linker command line.
  554.  
  555. =item *
  556.  
  557. LDLOADLIBS contains both the libraries found based on C<$potential_libs> and
  558. the CRTLs, if any, specified in Config.pm.  EXTRALIBS contains just those
  559. libraries found based on C<$potential_libs>.  BSLOADLIBS and LD_RUN_PATH
  560. are always empty.
  561.  
  562. =back
  563.  
  564. In addition, an attempt is made to recognize several common Unix library
  565. names, and filter them out or convert them to their VMS equivalents, as
  566. appropriate.
  567.  
  568. In general, the VMS version of ext() should properly handle input from
  569. extensions originally designed for a Unix or VMS environment.  If you
  570. encounter problems, or discover cases where the search could be improved,
  571. please let us know.
  572.  
  573. =head2 Win32 implementation
  574.  
  575. The version of ext() which is executed under Win32 differs from the
  576. Unix-OS/2 version in several respects:
  577.  
  578. =over 2
  579.  
  580. =item *
  581.  
  582. Input library and path specifications are accepted with or without the
  583. C<-l> and C<-L> prefices used by Unix linkers.  C<-lfoo> specifies the
  584. library C<libfoo.lib> (unless C<foo> already starts with C<lib>), and
  585. C<-Ls:ome\dir> specifies a directory to look for the libraries that follow.
  586. If neither prefix is present, a token is considered a directory to search
  587. if it is in fact a directory, and a library to search for otherwise.  The
  588. C<$Config{lib_ext}> suffix will be appended to any entries that are not
  589. directories and don't already have the suffix.  Authors who wish their
  590. extensions to be portable to Unix or OS/2 should use the Unix prefixes,
  591. since the Unix-OS/2 version of ext() requires them.
  592.  
  593. =item *
  594.  
  595. Entries cannot be plain object files, as many Win32 compilers will
  596. not handle object files in the place of libraries.
  597.  
  598. =item *
  599.  
  600. If C<$potential_libs> is empty, the return value will be empty.
  601. Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
  602. will be appended to the list of C<$potential_libs>.  The libraries
  603. will be searched for in the directories specified in C<$potential_libs>
  604. as well as in C<$Config{libpth}>. For each library that is found,  a
  605. space-separated list of fully qualified library pathnames is generated.
  606. You may specify an entry that matches C</:nodefault/i> in
  607. C<$potential_libs> to disable the appending of default libraries
  608. found in C<$Config{libs}> (this should be only needed very rarely).
  609.  
  610. =item *
  611.  
  612. The libraries specified may be a mixture of static libraries and
  613. import libraries (to link with DLLs).  Since both kinds are used
  614. pretty transparently on the win32 platform, we do not attempt to
  615. distinguish between them.
  616.  
  617. =item *
  618.  
  619. LDLOADLIBS and EXTRALIBS are always identical under Win32, and BSLOADLIBS
  620. and LD_RUN_PATH are always empty (this may change in future).
  621.  
  622. =item *
  623.  
  624. You must make sure that any paths and path components are properly
  625. surrounded with double-quotes if they contain spaces. For example,
  626. C<$potential_libs> could be (literally):
  627.  
  628.     "-Lc:\Program Files\vc\lib" msvcrt.lib "la test\foo bar.lib"
  629.  
  630. Note how the first and last entries are protected by quotes in order
  631. to protect the spaces.
  632.  
  633. =back
  634.  
  635.  
  636. =head1 SEE ALSO
  637.  
  638. L<ExtUtils::MakeMaker>
  639.  
  640. =cut
  641.  
  642.