Skip to content

Commit 1ed33a8

Browse files
committed
try harder to find libpng on FreeBSD
On FreeBSD, the libpng is versioned (something like -lpng16 or -lpng15).
1 parent 3131a40 commit 1ed33a8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

PNG/Makefile.PL

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,26 @@ my $all_libs;
3131
{
3232
warn "'pkg-config libpng' failed, continue with fallback values for cflags and libs...\n";
3333
$libpng_cflags = '-I/usr/local/include';
34-
$libpng_libs = '-lpng -lm';
34+
if ($^O eq 'freebsd')
35+
{
36+
my $real_libpng = readlink '/usr/local/lib/libpng.so';
37+
if (defined $real_libpng)
38+
{
39+
$real_libpng =~ s{^lib}{};
40+
$real_libpng =~ s{\.so$}{};
41+
$libpng_libs = "-l$real_libpng";
42+
warn "detected $libpng_libs on this system\n";
43+
}
44+
else
45+
{
46+
warn "No /usr/local/lib/libpng.so found, continue with default values (will probably fail)";
47+
$libpng_libs = '-lpng -lm';
48+
}
49+
}
50+
else
51+
{
52+
$libpng_libs = '-lpng -lm';
53+
}
3554
}
3655

3756
my $zlib_cflags;

0 commit comments

Comments
 (0)