🌻 📖 PkgConfig::LibPkgConf::Package

NAME

PkgConfig::LibPkgConf::Package - Represents a package

SYNOPSIS

 use PkgConfig::LibPkgConf::Client;
 
 my $client = PkgConfig::LibPkgConf::Client->new;
 $client->env;
 
 my $pkg = $client->find('libarchive');
 
 # use with system in scalar form:
 my $cflags = $pkg->cflags;
 my $libs = $pkg->libs;
 system "$cc $cflags foo.c";
 system "$cc -o foo foo.o $libs";
 
 # use with system in list form:
 my @cflags = $pkg->list_cflags;
 my @libs   = $pkg->list_libs;
 system $cc, @cflags, 'foo.c';
 system $cc, -p => 'foo', 'foo.o', @libs;

DESCRIPTION

The PkgConfig::LibPkgConf::Package object stores package information. Part of the package information is the compiler and linker flags. This can be fetched as strings with cflags and libs and as a list with list_cflags and list_libs. In the string form, escapes are retained, but in list form the white space escapes are converted into spaces. That means if you are using the string form of system/exec you should use the string accessors, and if you are using the list form of system/exec you should use the list accessors.

ATTRIBUTES

refcount

Internal reference count used by pkgconf.

id

The id of the package.

filename

The filename of the .pc file.

realname

The real name for the package.

version

The version of the package.

description

Description of the package.

url

URL for the package.

pc_filedir

TODO

METHODS

libs

Library flags. This usually includes things like -L/foo/lib and -lfoo.

libs_static

Static library flags.

cflags

Compiler flags. This usually includes things like -I/foo/include and -DFOO=1.

cflags_static

Static compiler flags.

list_libs

 my @fragments = $package->list_libs;

Library flags as a list of fragments PkgConfig::LibPkgConf::Fragment. This is similar to the libs method above, but since it returns a list instead of a single string, it can be used to filter for specific flags. For example:

 # equivalent to pkgconf --libs-only-L
 my @lib_dirs = grep { $_->type eq 'L' } $package->list_libs;
 # equivalent to pkgconf --libs-only-l
 my @libs = grep { $_->type eq 'l' } $package->list_libs;

list_libs_static

 my @fragments = $package->list_libs_static;

Similar to list_libs, but for the static libs flags.

list_cflags

 my @fragments = $package->list_cflags;

Compiler flags as a list of fragments PkgConfig::LibPkgConf::Fragment. This is similar to the cflags method above, but since it returns a list instead of a single string, it can be used to filter for specific flags. For example:

 # equivalent to pkgconf --cflags-only-I
 my @include_dirs = grep { $_->type eq 'I' } $package->list_cflags;
 # equivalent to pkgconf --cflags-only-other
 my @other_cflags = grep { $_->type ne 'I' } $package->list_cflags;

list_cflags_static

 my @fragments = $package->list_cflags_static;

Similar to list_cflags, but for the static compiler flags.

variable

 my $value = $package->variable($key);

Look up the value for the given variable. Returns the value if found, otherwise it will return undef (technically empty list).

SUPPORT

IRC #native on irc.perl.org

Project GitHub tracker:

https://github.com/plicease/PkgConfig-LibPkgConf/issues

If you want to contribute, please open a pull request on GitHub:

https://github.com/plicease/PkgConfig-LibPkgConf/pulls

SEE ALSO

For additional related modules, see PkgConfig::LibPkgConf

AUTHOR

Graham Ollis

For additional contributors see PkgConfig::LibPkgConf

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 Graham Ollis.

This is free software; you may redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.