Skip to content

Commit e47a9bb

Browse files
author
Gurusamy Sarathy
committed
MM_Win32.pm and Liblist.pm tweaks
p4raw-id: //depot/maint-5.005/perl@1746
1 parent 5e3006a commit e47a9bb

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

lib/ExtUtils/Liblist.pm

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ sub _win32_ext {
279279
next;
280280
}
281281

282-
my($found_lib)=0;
282+
my $found_lib = 0;
283283
foreach $thispth (@searchpath, @libpath){
284284
unless (-f ($fullname="$thispth\\$_")) {
285285
warn "'$thislib' not found as '$fullname'\n" if $verbose;
@@ -293,10 +293,14 @@ sub _win32_ext {
293293
}
294294

295295
# do another pass with (or without) leading 'lib' if they used -l
296-
if (!$found_lib and $thislib =~ /^-l/) {
297-
if ($GC) { s/^lib//i }
298-
else { $_ = "lib$_" }
299-
goto LOOKAGAIN unless $secondpass++;
296+
if (!$found_lib and $thislib =~ /^-l/ and !$secondpass++) {
297+
if ($GC) {
298+
goto LOOKAGAIN if s/^lib//i;
299+
}
300+
elsif (!/^lib/i) {
301+
$_ = "lib$_";
302+
goto LOOKAGAIN;
303+
}
300304
}
301305

302306
# give up
@@ -670,6 +674,10 @@ C<-lfoo> still happens as appropriate (depending on compiler being used,
670674
as reflected by C<$Config{cc}>), but the entries are not verified to be
671675
valid files or directories.
672676
677+
An entry that matches C</:search/i> reenables searching for
678+
the libraries specified after it. You can put it at the end to
679+
enable searching for default libraries specified by C<$Config{libs}>.
680+
673681
=item *
674682
675683
The libraries specified may be a mixture of static libraries and
@@ -697,7 +705,7 @@ to protect the spaces.
697705
698706
Since this module is most often used only indirectly from extension
699707
C<Makefile.PL> files, here is an example C<Makefile.PL> entry to add
700-
a set of libraries to the build process for an extension:
708+
a library to the build process for an extension:
701709
702710
LIBS => ['-lgl']
703711
@@ -708,6 +716,11 @@ C<$Config{libpth}>.
708716
When using a compiler other than GCC, the above entry will search for
709717
C<gl.lib> (followed by C<libgl.lib>).
710718
719+
If the library happens to be in a location not in C<$Config{libpth}>,
720+
you need:
721+
722+
LIBS => ['-Lc:\gllibs -lgl']
723+
711724
Here is a less often used example:
712725
713726
LIBS => ['-lgl', ':nosearch -Ld:\mesalibs -lmesa -luser32']
@@ -722,7 +735,9 @@ When using the Visual C compiler, the second item is returned as
722735
C<-libpath:d:\mesalibs mesa.lib user32.lib>.
723736
724737
When using the Borland compiler, the second item is returned as
725-
C<-Ld:\mesalibs mesa.lib user32.lib>.
738+
C<-Ld:\mesalibs mesa.lib user32.lib>, and MakeMaker takes care of
739+
moving the C<-Ld:\mesalibs> to the correct place in the linker
740+
command line.
726741
727742
=back
728743

lib/ExtUtils/MM_Win32.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ sub init_others
170170
$self->{'LD'} = $Config{'ld'} || 'link';
171171
$self->{'AR'} = $Config{'ar'} || 'lib';
172172
$self->{'LDLOADLIBS'} ||= $Config{'libs'};
173+
# -Lfoo must come first for Borland, so we put it in LDDLFLAGS
173174
if ($BORLAND) {
174175
my $libs = $self->{'LDLOADLIBS'};
175176
my $libpath = '';
176-
$libs = " $libs ";
177-
while ($libs =~ s/\s(("?)-L.+?\2)\s/ /g) {
177+
while ($libs =~ s/(?:^|\s)(("?)-L.+?\2)(?:\s|$)/ /) {
178178
$libpath .= ' ' if length $libpath;
179179
$libpath .= $1;
180180
}

0 commit comments

Comments
 (0)