From: Gurusamy Sarathy Date: Wed, 5 Aug 1998 22:55:59 +0000 (+0000) Subject: MM_Win32.pm and Liblist.pm tweaks X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e47a9bbca96e471a9294a62ab64a70b15c968ec0;p=p5sagit%2Fp5-mst-13.2.git MM_Win32.pm and Liblist.pm tweaks p4raw-id: //depot/maint-5.005/perl@1746 --- diff --git a/lib/ExtUtils/Liblist.pm b/lib/ExtUtils/Liblist.pm index 9df8752..b072c12 100644 --- a/lib/ExtUtils/Liblist.pm +++ b/lib/ExtUtils/Liblist.pm @@ -279,7 +279,7 @@ sub _win32_ext { next; } - my($found_lib)=0; + my $found_lib = 0; foreach $thispth (@searchpath, @libpath){ unless (-f ($fullname="$thispth\\$_")) { warn "'$thislib' not found as '$fullname'\n" if $verbose; @@ -293,10 +293,14 @@ sub _win32_ext { } # do another pass with (or without) leading 'lib' if they used -l - if (!$found_lib and $thislib =~ /^-l/) { - if ($GC) { s/^lib//i } - else { $_ = "lib$_" } - goto LOOKAGAIN unless $secondpass++; + if (!$found_lib and $thislib =~ /^-l/ and !$secondpass++) { + if ($GC) { + goto LOOKAGAIN if s/^lib//i; + } + elsif (!/^lib/i) { + $_ = "lib$_"; + goto LOOKAGAIN; + } } # give up @@ -670,6 +674,10 @@ C<-lfoo> still happens as appropriate (depending on compiler being used, as reflected by C<$Config{cc}>), but the entries are not verified to be valid files or directories. +An entry that matches C reenables searching for +the libraries specified after it. You can put it at the end to +enable searching for default libraries specified by C<$Config{libs}>. + =item * The libraries specified may be a mixture of static libraries and @@ -697,7 +705,7 @@ to protect the spaces. Since this module is most often used only indirectly from extension C files, here is an example C entry to add -a set of libraries to the build process for an extension: +a library to the build process for an extension: LIBS => ['-lgl'] @@ -708,6 +716,11 @@ C<$Config{libpth}>. When using a compiler other than GCC, the above entry will search for C (followed by C). +If the library happens to be in a location not in C<$Config{libpth}>, +you need: + + LIBS => ['-Lc:\gllibs -lgl'] + Here is a less often used example: LIBS => ['-lgl', ':nosearch -Ld:\mesalibs -lmesa -luser32'] @@ -722,7 +735,9 @@ When using the Visual C compiler, the second item is returned as C<-libpath:d:\mesalibs mesa.lib user32.lib>. When using the Borland compiler, the second item is returned as -C<-Ld:\mesalibs mesa.lib user32.lib>. +C<-Ld:\mesalibs mesa.lib user32.lib>, and MakeMaker takes care of +moving the C<-Ld:\mesalibs> to the correct place in the linker +command line. =back diff --git a/lib/ExtUtils/MM_Win32.pm b/lib/ExtUtils/MM_Win32.pm index 7f3a8d7..a1226b5 100644 --- a/lib/ExtUtils/MM_Win32.pm +++ b/lib/ExtUtils/MM_Win32.pm @@ -170,11 +170,11 @@ sub init_others $self->{'LD'} = $Config{'ld'} || 'link'; $self->{'AR'} = $Config{'ar'} || 'lib'; $self->{'LDLOADLIBS'} ||= $Config{'libs'}; + # -Lfoo must come first for Borland, so we put it in LDDLFLAGS if ($BORLAND) { my $libs = $self->{'LDLOADLIBS'}; my $libpath = ''; - $libs = " $libs "; - while ($libs =~ s/\s(("?)-L.+?\2)\s/ /g) { + while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) { $libpath .= ' ' if length $libpath; $libpath .= $1; }