Subject: | pkg_config_package_flags() does not work as documented |
Documentation reads:
pkg_config_package_flags($package, \%options?)
Search for pkg-config flags for package as specified. The flags which are
extracted are "--cflags" and "--libs". The extracted flags are appended to
the global "extra_compile_flags" and "extra_link_flags", respectively. In
case, no package configuration matching given criteria could be found,
return a "false" value (0).
But the extra_link_flags is not set for me. Here is a simple code that is supposed to read libstatgrab linker flags:
#!/usr/bin/perl
use Config::AutoConf;
my $c = Config::AutoConf->new;
$c->pkg_config_package_flags('libstatgrab') or die;
print 'extra_link_flags: ' . join(' ', @{$c->{extra_link_flags}}) . "\n";
print 'extra_libs: ' . join(' ', @{$c->{extra_libs}}) . "\n";
print '_get_extra_linker_flags: ' . $c->_get_extra_linker_flags . "\n";
print 'pkg-config --libs: ' . `pkg-config --libs libstatgrab`;
And the output is:
Checking for pkg-config... /usr/bin/pkg-config
Checking for pkg-config package of libstatgrab... -lstatgrab
extra_link_flags:
extra_libs: statgrab
_get_extra_linker_flags: -lstatgrab
pkg-config --libs: -lstatgrab
As you can see the extra_link_flags array is empty contrary to the documentation. When reading Config::AutoConf I found that extra_libs and _get_extra_linker_flags.
It looks like _get_extra_linker_flags method is the right way how to retrieve the linker flags. Is it possible to correct the code or the documentation?
I found it when investigating Unix-Statgrab failure after Config-Autoconf upgrade (CPAN RT#125204).