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;
}
# 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
as reflected by C<$Config{cc}>), but the entries are not verified to be
valid files or directories.
+An entry that matches C</:search/i> 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
Since this module is most often used only indirectly from extension
C<Makefile.PL> files, here is an example C<Makefile.PL> 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']
When using a compiler other than GCC, the above entry will search for
C<gl.lib> (followed by C<libgl.lib>).
+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']
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
$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;
}