---
name: "pkg.m4"
section: "7"
platform: "linux"
package: "pkgconf"
version: "3.0.10-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/pkg.m4"
---

# pkg.m4(7)

autoconf macros for using pkgconf

## NAME

**pkg.m4** – 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

**pkg.m4** is a collection of autoconf macros which help to configure compiler and linker flags for development libraries. This allows build systems to detect other dependencies and use them with the system toolchain.

## AUTOCONF MACROS

### PKG\_PREREQ(MIN-VERSION)

Checks that the version of the **pkg.m4** autoconf macros in use is at least MIN-VERSION. This can be used to ensure a particular **pkg.m4** macro will be available.

### PKG\_PROG\_PKG\_CONFIG(\[MIN-VERSION\])

Checks for an implementation of **pkg-config** which is 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\]\])

Checks whether a given module set exists, and if so, defines **CFLAGS** and **LIBS** variables prefixed by **VARIABLE-PREFIX** with the output from **--cflags** and **--libs** respectively.

The optional **ACTION-IF-FOUND** and **ACTION-IF-NOT-FOUND** arguments are shell fragments that should be executed if the module set is found or not found.

If **$PKG\_CONFIG** is not defined, the **PKG\_PROG\_PKG\_CONFIG** macro will be executed to locate a **pkg-config** implementation.

The **PKG\_CHECK\_MODULES\_STATIC** macro provides the same behaviour as **PKG\_CHECK\_MODULES** with static linking enabled via the **--static** flag.

### PKG\_INSTALLDIR(DIRECTORY)

Defines the variable $pkgconfigdir as the location where a package should install pkg-config .pc files.

By default the directory is $libdir/pkgconfig, but the default can be changed by passing the **DIRECTORY** parameter.

This value can be overridden with the **--with-pkgconfigdir** configure parameter.

### PKG\_NOARCH\_INSTALLDIR(DIRECTORY)

Defines the variable $noarch\_pkgconfigdir as the location where a package should install pkg-config .pc files.

By default the directory is $datadir/pkgconfig, but the default can be changed by passing the **DIRECTORY** parameter.

This value can be overridden with the **--with-noarch-pkgconfigdir** configure parameter.

### PKG\_CHECK\_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, \[ACTION-IF-FOUND\], \[ACTION-IF-NOT-FOUND\])

Retrieves the value of the **pkg-config** variable **CONFIG-VARIABLE** from **MODULE** and stores it in the **VARIABLE** variable.

Note that repeated usage of **VARIABLE** is not recommended as the check will be skipped if the variable is already set.

### PKG\_WITH\_MODULES(VARIABLE-PREFIX, MODULES, \[ACTION-IF-FOUND\],\[ACTION-IF-NOT-FOUND\], \[DESCRIPTION\], \[DEFAULT\])

Prepares a "--with-" configure option using the lowercase **VARIABLE-PREFIX** name, merging the behaviour of **AC\_ARG\_WITH** and **PKG\_CHECK\_MODULES** in a single macro.

### PKG\_HAVE\_WITH\_MODULES(VARIABLE-PREFIX, MODULES, \[DESCRIPTION\], \[DEFAULT\])

Convenience macro to trigger **AM\_CONDITIONAL** after a **PKG\_WITH\_MODULES** **check.** **VARIABLE-PREFIX** is exported as a make variable.

### PKG\_HAVE\_DEFINE\_WITH\_MODULES(VARIABLE-PREFIX, MODULES, \[DESCRIPTION\], \[DEFAULT\])

Convenience macro to trigger **AM\_CONDITIONAL** and **AC\_DEFINE** after a **PKG\_WITH\_MODULES** **check.** **VARIABLE-PREFIX** is exported as a make variable.
