Permalink
Browse files

if we can't find both headers and libraries ourselves, and the caller

supplied test code, try asking the compiler if it can find what's needed

Assumes non-trivial test code
  • Loading branch information...
1 parent e443ec2 commit e92a36872b5094f8021b46f532b269ec5bee9349 Tony Cook committed Aug 6, 2010
Showing with 34 additions and 0 deletions.
  1. +34 −0 lib/Imager/Probe.pm
View
@@ -19,6 +19,10 @@ sub probe {
if (!$result && $req->{inccheck} && ($req->{libcheck} || $req->{libbase})) {
$result = _probe_check($req);
}
+
+ if (!$result && $req->{testcode}) {
+ $result = _probe_fake($req);
+ }
$result or return;
if ($req->{testcode}) {
@@ -162,6 +166,36 @@ sub _probe_check {
};
}
+sub _probe_fake {
+ my ($req) = @_;
+
+ # the caller provided test code, and the compiler may look in
+ # places we don't, see Imager-Screenshot ticket 56793,
+ # so fake up a result so the test code can
+ my $lopts;
+ if ($req->{libopts}) {
+ $lopts = $req->{libopts};
+ }
+ elsif (defined $req->{libbase}) {
+ # might not need extra libraries, eg. Win32 perl already links
+ # everything
+ $lopts = $req->{libbase} ? "-l$req->{libbase}" : "";
+ }
+ if (defined $lopts) {
+ print "$req->{name}: Checking if the compiler can find them on it's own\n";
+ return
+ {
+ INC => "",
+ LIBS => $lopts,
+ };
+ }
+ else {
+ print "$req->{name}: Can't fake it - no libbase or libopts\n"
+ if $req->{verbose};
+ return;
+ }
+}
+
sub _probe_test {
my ($req, $result) = @_;

0 comments on commit e92a368

Please sign in to comment.