Build Systems: autotools, meson, cmake, meson+ninja

Updated

October 30, 2026

Build Systems: autotools, meson, cmake, meson+ninja

As a distribution maintainer, you will encounter diverse upstream build systems. Knowing how to configure, steer, and stage each build system is essential.

+-------------------------------------------------------------+
|                  Modern Build Systems Landscape             |
|                                                             |
| System       Configuration Command        Compilation Engine|
| ----------------------------------------------------------- |
| Autotools    ./configure --prefix=/usr    GNU Make          |
| CMake        cmake -B build -G Ninja ...  Ninja / Make      |
| Meson        meson setup build ...        Ninja             |
| Cargo (Rust) cargo build --release        rustc / LLVM      |
+-------------------------------------------------------------+

1. GNU Autotools (autoconf, automake, libtool)

Autotools is the classic build system of the GNU project. It is characterized by the ubiquitous ./configure && make && make install workflow.

Standard Distro Invocation:

./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --disable-static \
    --enable-shared \
    --build=$CHOST \
    --host=$CHOST
make -j$(nproc)
make DESTDIR=$PKGDIR install

Key Caveat: The DESTDIR Variable

When testing or staging software, never run plain make install! Plain make install will overwrite files in your host workstation’s /usr directory. Standard autotools makefiles support the DESTDIR variable:

make DESTDIR=/tmp/staged-package install

This prepends /tmp/staged-package to every installation path (installing binaries to /tmp/staged-package/usr/bin/ instead of /usr/bin/).

2. CMake (Cross-Platform Make)

Used by KDE, LLVM, and modern C++ projects. CMake inspects system capabilities and generates native build files (either Makefile or build.ninja).

Standard Distro Invocation (using Ninja backend):

cmake -B build -G Ninja \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_SHARED_LIBS=ON \
    -DCMAKE_SKIP_INSTALL_RPATH=ON
ninja -C build -j$(nproc)
DESTDIR=$PKGDIR ninja -C build install

3. Meson & Ninja

Meson has become the standard build system for modern GNOME, Wayland, systemd, and system libraries. Written in Python, Meson generates optimized Ninja build manifests.

Why Meson & Ninja are Preferred:

  • Blazing Fast Configuration: Parses declarative meson.build files in seconds.
  • Strict Prefix Validation: Warns immediately if headers or libraries escape the intended sysroot.
  • Deterministic Parallelism: Ninja maximizes CPU saturation across all threads.

Standard Distro Invocation:

meson setup build \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libdir=lib \
    --buildtype=release \
    -Ddefault_library=shared
ninja -C build -j$(nproc)
DESTDIR=$PKGDIR ninja -C build install