PKG-CONFIG(1)
π¦ PKG-CONFIG(1) π¦
okay so this is the PKG-CONFIG(1) page from the User Contributed Perl Documentation, and it's all about PkgConfig β a pure-Perl, core-only replacement for pkg-config. bestie, get comfy, there's a lot here and it's honestly kind of iconic. π
β¨ NAME β¨
PkgConfig β Pure-Perl Core-Only replacement for pkg-config. no glib, no compiled binary, just vibes and Perl. π
πΈ SYNOPSIS πΈ
π As a replacement for pkg-config
$ ppkg-config --libs --cflags --static gio-2.0
#outputs (lines artificially broken up for readability):
# -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
# -pthread -lgio-2.0 -lz -lresolv -lgobject-2.0
# -lgmodule-2.0 -ldl -lgthread-2.0 -pthread -lrt -lglib-2.0
pkg-config.pl can be used as an alias for ppkg-config on platforms that support it. it can also be installed as pkg-config, though this is not recommended if your system has a native pkg-config. lowkey don't do that. π
Compare to:
$ pkg-config --libs --cflags --static gio-2.0
#outputs ( "" ):
# -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
# -pthread -lgio-2.0 -lz -lresolv -lgobject-2.0 -lgmodule-2.0
# -ldl -lgthread-2.0 -lrt -lglib-2.0
π§ From another Perl module
use PkgConfig;
my $o = PkgConfig->find('gio');
if($o->errmsg) {
#handle error
} else {
my $prefix = $o->get_var('prefix');
my @cflags = $o->get_cflags;
my @ldflags = $o->get_ldflags;
}
π DESCRIPTION π
PkgConfig provides a pure-perl, core-only replacement for the pkg-config utility. slay. β¨
fr fr though: this is not a description of what pkg-config is used for. it's a description of the differences between the C version and the Perl one. that's the whole assignment. π«Ά
while pkg-config is a compiled binary linked with glib, the pure-perl version has no such requirement, and will run wherever Perl ( >= 5.6 ) does. literally anywhere. it's giving portability queen. π
the main supported options are the common --libs, --cflags, --static, --exists and --modversion.
π SCRIPT OPTIONS π
β USAGE β
<packagename1 pkgname2..> [ --options ]
π ARGUMENTS π
By default, a library name must be supplied unless one of --version, or --real-version is specified.
The output should normally be suitable for passing to your favorite compiler. π
--libsβ (Also) print linker flags. Dependencies are traversed in order. Top-level dependencies will appear earlier in the command line than bottom-level dependencies. order matters, bestie, don't come for me. π₯--libs-only-Lβ Prints the -L/-R part of--libs. It defines the library search path but without the libraries to link with.--libs-only-lβ Prints the -l part of--libs.--libs-only-otherβ Prints the part of--libsnot covered by--libs-only-Land--libs-only-l, such as--pthread.--list-allβ List all known packages.--cflagsβ (Also) print compiler and C preprocessor flags.--cflags-only-Iβ Prints the -I part of--cflags.--cflags-only-otherβ Prints the parts of--cflagsnot covered by--cflags-only-I.--modversionβ Print the version of a given package.--staticβ Use extra dependencies and libraries if linking against a static version of the requested library.--existsβ Return success (0) if the package exists in the search path.--with-path=PATHβ PrependPATHto the list of search paths containing.pcfiles. this option can be specified multiple times with different paths, and they will all be added. stacking, we love to see it. π«Ά--env-onlyβ Using this option, only paths specified inPKG_CONFIG_PATHare recognized and any hard-coded defaults are ignored.--guess-pathsβ Invokegccandldto determine default linker and include paths. Default paths will be excluded from explicit -L and -I flags.--define-variable=VARIABLE=VALUEβ Define a variable, overriding any such variable definition in the .pc file, and allowing your value to interpolate with subsequent uses.--variable=VARIABLEβ This returns the value of a variable defined in a package's .pc file.--print-variablesβ Print all defined variables found in the .pc files.--versionβ The target version ofpkg-configemulated by this script.--real-versionβ The actual version of this script. (yes, she has range. π )--debugβ Print debugging information.--silence-errorsβ Turn off errors. This is the default for non-libs/cflag/modversion arguments.--print-errorsβ Print errors to STDERR and takes precedence over--silence-errors.--short-errorsβ Ignored, but recognized for compatibility. it's just there to be there, honestly. π--errors-to-stdoutβ Print errors to STDOUT and takes precedence over--print-errors.
π¦ ENVIRONMENT π¦
the PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR variables are honored and used as a colon-delimited (semicolon-delimited on Windows) list of directories which contain .pc files.
Other environment variables recognized by both pkg-config and PkgConfig include:
PKG_CONFIG_ALLOW_SYSTEM_CFLAGSPKG_CONFIG_ALLOW_SYSTEM_LIBS
If Win32API::Registry is installed, on Windows (but not Cygwin) PkgConfig will also consult these registry keys. The names are ignored, but the values are paths containing .pc files.
HKEY_CURRENT_USER\Software\pkgconfig\PKG_CONFIG_PATHHKEY_LOCAL_MACHINE\Software\pkgconfig\PKG_CONFIG_PATH
Registry support should be considered somewhat experimental, subject to change in the future, though not without good reason. The rationale for this caveat is that this feature is documented in several places, but I have yet to find a working version that implements this feature. π so like... it's documented, but nobody's actually seen it work. consider yourself warned.
π MODULE OPTIONS π
π PkgConfig->find
my $result = PkgConfig->find($library, %options);
Find a library and return a result object. $library can be either a single name of a library, or a reference to an array of library names. either way, she'll handle it. β¨
The options are in the form of hash keys and values, and the following are recognized:
search_path,search_path_overrideβ Prepend search paths in addition to the paths specified in$ENV{PKG_CONFIG_PATH}. The value is an array reference. the_overridevariant ignores defaults (likePKG_CONFIG_PATH). πfile_pathβ Specifies the full path of the .pc file that you wish to load. It does not need to be in the search path (although any dependencies will need to be). Useful if you know the full path of the exact .pc file that you want. iykyk. π―exclude_cflags,exclude_ldflags,exclude_cflags_override,exclude_ldflags_overrideβ Some.pcfiles specify default compiler and linker search paths, e.g.-I/usr/include -L/usr/lib. Specifying them on the command line can be problematic as it drastically changes the search order. The above options will either append or replace the options which are excluded and filtered. The default excluded linker and compiler options can be obtained via@PkgConfig::DEFAULT_EXCLUDE_LFLAGSand@PkgConfig::DEFAULT_EXCLUDE_CFLAGS, respectively. π§staticβ Also specify static libraries.no_recurseβ Do not recurse dependencies. This is useful for just doing version checks. minimal effort, maximum result. πVARSβ Define a hashref of variables to override any variable definitions within the .pc files. This is equivalent to the--define-variablecommand-line option.
A PkgConfig object is returned and may be queried about the results:
$o->errmsgβ An error message, if any. This is a string and indicates an error.$o->pkg_existsβ Boolean value, true if the package exists.$o->pkg_versionβ The version of the package.$o->get_cflags,$o->get_ldflagsβ Returns compiler and linker flags, respectively. In list context, these methods return a list with each argument split on unescaped spaces. In list context returns a list of compiler and linker flags, respectively. In scalar context returns a string of compiler and linker flags with spaces and quotes escaped correctly.$o->get_var($name)β Get the variable with the given name.
πΈ PkgConfig->Guess
This is a class method, and will replace the hard-coded default linker and include paths with those discovered by invoking ld(1) and cpp(1). π
Currently this only works with GCC-supplied ld and GNU ld.
π INSTALL π
The Makefile.PL that comes with PkgConfig can take one or more --script options to change the name of the script or scripts that are installed. name your baby whatever you want, honestly. π
--script ppkg-configβ This is the default and works on all platforms. π--script pkg-config.plβ This is installed by default on all platforms except for Windows, where the .pl may confuse the shell and cause the script to be opened in a text editor. π (not the text editor jumpscare)--script pkg-configβ This is the default name of the realpkg-configand so you have to specifically enable it if you want it.--script noneβ Don't install any scripts. the void. π
Example, install all script names:
% perl Makefile.PL --script ppkg-config --script pkg-config.pl --script pkg-config
Example, don't install any scripts:
% perl Makefile.PL --script none
You can also set the environment variable PERL_PKG_CONFIG_SCRIPTS to the desired --script value (separating each script name with a comma ,) to ensure that upgrades of PkgConfig do the same. set it and forget it, bestie. π«Ά
β CAVEATS β
On Strawberry Perl ppkg-config acts like Strawberry is the system. This means that:
- The .pc files that are bundled with Strawberry are searched by default.
- The Strawberry include and lib directories are used to compute the exclusion lists.
As of Strawberry 5.20.0.1 PkgConfig is bundled with Strawberry and pkg-config is installed by default (in addition to ppkg-config, though the ppkg-config alias is NOT bundled with Strawberry itself).
For details on how to patch the .pc files bundled with older Strawberries, see the README.win32 that comes with this Distribution.
π§ BUGS π§
The order of the flags is not exactly matching to that of pkg-config. From my own observation, it seems this module does a better job, but I might be wrong. π (humble queen behavior, honestly)
Unlike pkg-config, the scripts' --exists function will return nonzero if a package or any of its dependencies are missing. This differs from the behavior of pkg-config, which will just check for the definition of the package itself (without dependencies). β οΈ different behavior, so don't get caught out.
π SEE ALSO π
ok so if you wanna go deeper (and honestly, why wouldn't you, you're doing amazing sweetie π), here's the whole extended universe of pkg-config implementations and friends:
pkg-configβ <http://www.freedesktop.org/wiki/Software/pkg-config> The original C implementation. The blueprint. The blueprint that said "I was here first." πpkgconfβ <https://github.com/pkgconf/pkgconf> An alternative C implementation. Another C icon doing its own thing, no cap. β¨PkgConfig::LibPkgConfPerl bindings forlibpkgconfβ and like, that's literally the same library thatpkgconfis built on, so you know it's the real deal π«ΆExtUtils::PkgConfigA wrapper around thepkg-configbinary that you can use in yourMakefile.PLorBuild.PL. Perl build system bestie behaviour fr fr π- <http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/pkg-config/> Another perl implementation of pkg-config. (lowercase "perl" is how they wrote it, and honestly? iconic of them π )
pkg-configβ <https://github.com/ruby-gnome2/pkg-config> Pure Ruby implementation. Ruby girlies rise πpykg-configβ <https://pypi.python.org/pypi/pykg-config/1.2.0> A Python implementation. Slithering in with the vibes πβ¨
π AUTHOR π
ok the lore drop, gather round:
- Original Author: M. Nunberg
- Current maintainer: Graham Ollis
<plicease@cpan.org>
and the other contributors include (a whole ensemble cast, main character energy all around π):
- Vladimir Timofeev (vovkasm)
- kmx
- Sanel Zukan
- Breno G. de Oliveira (garu)
- Gregor Herrmann
- Ilya Pavlov (ILUX, Ilya33)
- Shawn Laffan (SLAFFAN, shawnlaffan)
- Ari Jolma (AJOLMA)
π COPYRIGHT AND LICENSE π
Copyright (C) 2012 M. Nunberg
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so yes, free as in go off, do your thing, just keep the terms, bestie π¦
π one gentle reminder: that license line is a real legal thing, not a vibe β if you're redistributing, keep it exactly as the Perl 5 terms say. The fairy emoji will not protect you in court π§
and that's a wrap on the whole page, bestie!! go configure some packages, you absolute legend π₯
β signed off from perl v5.42.0, dated 2020-11-12, under the title PKG-CONFIG(1) β β mwah, love u, bye π
π¦ where this page comes from
- opensuse-leap 16.0: perl-PkgConfig 0.25026-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-PkgConfig 0.25026-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-PkgConfig 0.25026-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-PkgConfig 0.25026-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms