Module::Build::Using::PkgConfig(3pm) | User Contributed Perl Documentation | Module::Build::Using::PkgConfig(3pm) |
"Module::Build::Using::PkgConfig" - extend "Module::Build" to more easily use platform libraries provided by pkg-config
In Build.PL:
use Module::Build::Using::PkgConfig; my $build = Module::Build::Using::PkgConfig->new( module_name => "Module::Here", ... # other arguments as per Module::Build ); # A platform library provided by pkg-config $build->use_pkgconfig( "libfoo" ); # We need at least a given version $build->use_pkgconfig( "libbar", atleast_version => "0.5", ); # A platform librariy that's also wrapped as an Alien module $build->use_pkgconfig( "libsplot", atleast_version => "1.0", alien => "Alien::libsplot", alien_version => "0.05", # Alien::libsplot 0.05 provides libsplot v1.0 ); $build->create_build_script;
This subclass of Module::Build provides some handy methods to assist the Build.PL script of XS-based module distributions that make use of platform libraries managed by pkg-config.
As well as supporting libraries installed on a platform-wide basis and thus visible to pkg-config itself, this subclass also assists with "Alien::"-based wrappers of these system libraries, allowing them to be dynamically installed at build time if the platform does not provide them.
This module also provides some helper code to generate the required "RPATH" arguments needed to link against the libraries found by inspecting the "extra_linker_flags". This attempts to duplicate the same logic performed by libtool when it would link a C program or library, as we don't get to use its code when linking dynamic libraries for Perl.
$build->use_pkgconfig( $modname, ... )
Requires the given pkg-config module of the given version, and extends the compiler and linker arguments sufficient to build from it.
Takes the following named options:
If this module is not yet available and the "no_late_alien" option is not true, the Alien module is added to the "requires" dynamic dependencies and checked again at "build" action time.
If neither the pkg-config module and no "Alien::" module was requested (or none was found and "no_late_alien" was set), this method dies with an "OS unsupported" message, which is usually what is required for a Build.PL script.
$ok = $build->try_pkconfig( $modname, ... )
Boolean-returning version of "use_pkgconfig". If successful, returns true. If it fails it returns false rather than dying, allowing the Build.PL script to take alternative action.
$ok = $build->pkgconfig_atleast_version( $modname, $modver )
Returns true if the pkg-config module name exists and has at least the given version.
$build->add_cflags_libs_from_pkgconfig( $modname )
Extend the "extra_compiler_flags" and "extra_linker_flags" arguments from the "--cflags" and "--libs" from the given pkg-config module name.
$ok = $build->alien_atleast_version( $alien, $modver )
Returns true if the given "Alien::" module provides a pkg-config module version at least the given version.
$build->add_cflags_libs_from_alien( $alien )
Extend the "extra_compiler_flags" and "extra_linker_flags" arguments from the "--cflags" and "--libs" from the given "Alien::" module name.
$ok = $build->use_late_alien( $alien, ... )
Adds an Alien module directly to the "requires" hash, and makes a note to use its cflags and libraries later at build time.
Normally this method would not be necessary as it is automatically called from use_pkgconfig if required, but one use-case may be to provide a final last-ditch attempt after trying some other possible attempts, after an earlier call to "use_pkgconfig" with "no_late_alien" set.
$build->push_extra_compiler_flags( @flags )
Appends more values onto the "extra_compiler_flags".
$build->push_extra_linker_flags( @flags )
Appends more values onto the "extra_linker_flags".
Paul Evans <leonerd@leonerd.org.uk>
2022-11-30 | perl v5.36.0 |