PKG.M4(7)
โจ NAME โจ
okay so the name of this page is pkg.m4, and it's giving autoconf macros for using pkgconf ๐
๐ SYNOPSIS ๐
PKG_PREREQ
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES
PKG_CHECK_MODULES_STATIC
PKG_INSTALLDIR
PKG_NOARCH_INSTALLDIR
PKG_CHECK_VAR
PKG_WITH_MODULES
PKG_HAVE_WITH_MODULES
PKG_HAVE_DEFINE_WITH_MODULES
๐ฆ DESCRIPTION ๐ฆ
bestie, pkg.m4 is a whole collection of autoconf macros that help you set up compiler and linker flags for development libraries ๐ฅ Your build system can detect other dependencies and then use them with the system toolchain. literally so useful, no cap.
๐ AUTOCONF MACROS ๐
๐ธ PKG_PREREQ(MIN-VERSION)
this one checks that the version of the pkg.m4 autoconf macros you're using is at least MIN-VERSION ๐ซถ It's how you make sure a particular pkg.m4 macro is actually going to be there when you need it.
โจ PKG_PROG_PKG_CONFIG([MIN-VERSION])
checks for an implementation of pkg-config that's at least MIN-VERSION or newer ๐
๐ง PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
๐ง PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
this is the iconic one ๐ It checks whether a given module set exists, and if it does, it defines CFLAGS and LIBS variables prefixed by VARIABLE-PREFIX, filled with the output from --cflags and --libs respectively.
the optional ACTION-IF-FOUND and ACTION-IF-NOT-FOUND arguments are shell fragments that get executed if the module set is found or not found ๐
if $PKG_CONFIG isn't defined, the PKG_PROG_PKG_CONFIG macro will run to go find a pkg-config implementation ๐
and PKG_CHECK_MODULES_STATIC gives you the same behaviour as PKG_CHECK_MODULES, except with static linking turned on via the --static flag ๐
๐ PKG_INSTALLDIR(DIRECTORY)
this one defines the variable $pkgconfigdir as the spot where a package should install its pkg-config .pc files ๐ฆ
by default that directory is $libdir/pkgconfig, but you can change the default by passing in the DIRECTORY parameter ๐ ๏ธ
and if you want to override it, use the --with-pkgconfigdir configure parameter ๐
๐ PKG_NOARCH_INSTALLDIR(DIRECTORY)
this one defines the variable $noarch_pkgconfigdir as the spot where a package should install its pkg-config .pc files, but for the architecture-independent stuff ๐ฆ
by default that directory is $datadir/pkgconfig, but again, you can change it by passing in the DIRECTORY parameter ๐ธ
to override it, use the --with-noarch-pkgconfigdir configure parameter โจ
๐ฎ PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
this one grabs the value of the pkg-config variable CONFIG-VARIABLE from MODULE and stores it in the VARIABLE variable ๐ง
heads up: using VARIABLE more than once is not recommended! The check gets skipped if the variable is already set, so don't be surprised when your second call does nothing ๐
๐ PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND], [DESCRIPTION], [DEFAULT])
this one sets up a "--with-" configure option using the lowercase VARIABLE-PREFIX name ๐จ It merges the behaviour of AC_ARG_WITH and PKG_CHECK_MODULES into one single macro, so you get two-in-one energy ๐
๐ PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES, [DESCRIPTION], [DEFAULT])
a cute little convenience macro that triggers AM_CONDITIONAL after a PKG_WITH_MODULES check ๐ซถ VARIABLE-PREFIX gets exported as a make variable.
๐ PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES, [DESCRIPTION], [DEFAULT])
same vibe as above, but this one triggers both AM_CONDITIONAL and AC_DEFINE after a PKG_WITH_MODULES check ๐ฅ And yep, VARIABLE-PREFIX gets exported as a make variable too.
bestie, that's the whole page ๐ Brought to you by Debian, last updated December 5, 2017, filed under PKG.M4(7) ๐โจ slay the autoconf! ๐ ๐ฆ
๐ฆ where this page comes from
- alpine 3.22: pkgconf-doc 2.4.3-r0 ยท ISC
- alpine 3.23: pkgconf-doc 2.5.1-r0 ยท ISC
- alpine 3.24: pkgconf-doc 2.5.1-r0 ยท ISC
- arch rolling: pkgconf 3.0.10-1 ยท ISC
- arch rolling: pkgconf 3.0.7-1
- centos-stream 10: pkgconf-m4 2.1.0-3.el10 ยท GPLv2+ with exceptions
- centos-stream 9: pkgconf-m4 1.7.3-10.el9 ยท GPLv2+ with exceptions
- debian bookworm: pkgconf 1.8.1-1 ยท ISC
- debian trixie: pkgconf 1.8.1-4 ยท ISC
- fedora 43: pkgconf-m4 2.3.0-3.fc43 ยท GPL-2.0-or-later WITH Autoconf-exception-generic
- fedora 44: pkgconf-m4 2.5.1-1.fc44 ยท GPL-2.0-or-later WITH Autoconf-exception-generic
- nixpkgs unstable: pkgconf 2.5.1
- opensuse-leap 16.0: pkgconf-m4 2.2.0-160000.2.2 ยท GPL-2.0-or-later WITH Autoconf-exception-2.0
- ubuntu jammy: pkgconf 1.8.0-1 ยท ISC
- ubuntu noble: pkgconf 1.8.1-2build1 ยท ISC
- ubuntu questing: pkgconf 1.8.1-4build1 ยท ISC
- ubuntu resolute: pkgconf 2.5.1-4 ยท ISC
- ubuntu stonking: pkgconf 2.5.1-4 ยท ISC
- Copyright (c) 2017 pkgconf authors (see AUTHORS)
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms