1Imager::Probe(3) User Contributed Perl Documentation Imager::Probe(3)
2
3
4
6 Imager::Probe - hot needle of inquiry for libraries
7
9 require Imager::Probe;
10
11 my %probe =
12 (
13 # short name of what we're looking for (displayed to user)
14 name => "FOO",
15 # pkg-config lookup
16 pkg => [ qw/name1 name2 name3/ ],
17 # perl subs that probe for the library
18 code => [ \&foo_probe1, \&foo_probe2 ],
19 # or just: code => \&foo_probe,
20 inccheck => sub { ... },
21 libcheck => sub { ... },
22 # search for this library if libcheck not supplied
23 libbase => "foo",
24 # library link time options, uses libbase to build options otherwise
25 libopts => "-lfoo",
26 # C code to check the library is sane
27 testcode => "...",
28 # header files needed
29 testcodeheaders => [ "stdio.h", "foo.h" ],
30 );
31 my $result = Imager::Probe->probe(\%probe)
32 or print "Foo library not found: ",Imager::Probe->error;
33
35 Does the probes that were hidden in Imager's Makefile.PL, pulled out so
36 the file format libraries can be externalized.
37
38 The return value is either nothing if the probe fails, or a hash
39 containing:
40
41 • "INC" - "-I" and other C options
42
43 • "LIBS" - "-L", "-l" and other link-time options
44
45 • "DEFINE" - "-D" options, if any.
46
47 The possible values for the hash supplied to the probe() method are:
48
49 • "pkg" - an array of pkg-config names to probe for. If the pkg-
50 config checks pass, "inccheck" and "libcheck" aren't used.
51
52 • "inccheck" - a code reference that checks if the supplied include
53 directory contains the required header files.
54
55 • "libcheck" - a code reference that checks if the supplied library
56 directory contains the required library files. Note: the
57 Makefile.PL version of this was supplied all of the library file
58 names instead. "libcheck" can also be an arrayref of library check
59 code references, all of which must find a match for the library to
60 be considered "found".
61
62 • "libbase" - if "inccheck" is supplied, but "libcheck" isn't, then a
63 "libcheck" that checks for "lib"libbase$Config{_a} and
64 "lib"libbase.$Config{so} is created. If "libopts" isn't supplied
65 then that can be synthesized as "-llibbase". "libbase" can also be
66 an arrayref of library base names to search for, in which case all
67 of the libraries mentioned must be found for the probe to succeed.
68
69 • "libopts" - if the libraries are found via "inccheck"/"libcheck",
70 these are the "-l" options to supply during the link phase.
71
72 • "code" - a code reference to perform custom checks. Returns the
73 probe result directly. Can also be an array ref of functions to
74 call.
75
76 • "testcode" - test C code that is run with Devel::CheckLib. You
77 also need to set "testcodeheaders".
78
79 • "testcodeprologue" - C code to insert between the headers and the
80 main function.
81
82 • "incpath" - $Config{path_sep} separated list of header file
83 directories to check, or a reference to an array of such.
84
85 • "libpath" - $Config{path_sep} separated list of library file
86 directories to check, or a reference to an array of such.
87
88 • "alternatives" - an optional array reference of alternate
89 configurations (as hash references) to test if the primary
90 configuration isn't successful. Each alternative should include an
91 "altname" key describing the alternative. Any key not mentioned in
92 an alternative defaults to the value from the main configuration.
93
95 Tony Cook <tonyc@cpan.org>, Arnar M. Hrafnkelsson
96
97
98
99perl v5.34.0 2021-07-22 Imager::Probe(3)