Build patterns
A recipe’s build is an arbitrary shell script; here are the common patterns.
All of them install into ZPKG_DESTROOT and stop on failure with set -e.
autotools
Section titled “autotools”#!/bin/shset -ecd "$ZPKG_SRC/foo-$ZPKG_VERSION"./configure --prefix=/usrmake -j"$(nproc)"make DESTDIR="$ZPKG_DESTROOT" install#!/bin/shset -ecd "$ZPKG_SRC/foo-$ZPKG_VERSION"cmake -S . -B build \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_INSTALL_LIBDIR=lib \ -DBUILD_TESTING=OFFcmake --build build -j"$(nproc)"DESTDIR="$ZPKG_DESTROOT" cmake --install buildSome projects install into /usr/lib64 unless CMAKE_INSTALL_LIBDIR=lib is
set explicitly. ZIGNOS standardizes on /usr/lib.
#!/bin/shset -ecd "$ZPKG_SRC/foo-$ZPKG_VERSION"meson setup build --prefix=/usr --libdir=libninja -C buildDESTDIR="$ZPKG_DESTROOT" meson install -C build#!/bin/shset -ecd "$ZPKG_SRC/foo-$ZPKG_VERSION"cargo build --release --lockedinstall -Dm755 target/release/foo "$ZPKG_DESTROOT/usr/bin/foo"#!/bin/shset -ecd "$ZPKG_SRC/foo-$ZPKG_VERSION"GOTOOLCHAIN=local go build -trimpath -buildvcs=false \ -o "$ZPKG_DESTROOT/usr/bin/foo" ./cmd/fooPython
Section titled “Python”Follow the instructions in pyproject.toml / setup.py. When using pip, make
sure pip is present in the build environment via makedepends.
#!/bin/shset -ecd "$ZPKG_SRC/foo-$ZPKG_VERSION"python3 -m pip install --root="$ZPKG_DESTROOT" --prefix=/usr --no-deps .#!/bin/shset -ecd "$ZPKG_SRC/foo-$ZPKG_VERSION"perl Makefile.PL INSTALL_BASE=/usrmakemake DESTDIR="$ZPKG_DESTROOT" installQt / KDE
Section titled “Qt / KDE”#!/bin/shset -ecd "$ZPKG_SRC/foo-$ZPKG_VERSION"cmake -S . -B build \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_INSTALL_LIBDIR=lib \ -DBUILD_TESTING=OFFcmake --build build -j"$(nproc)"DESTDIR="$ZPKG_DESTROOT" cmake --install buildKDE applications put ECM and Qt 6 in makedepends. Some projects run
add_subdirectory(tests) unconditionally even when tests are disabled, so
patch the recipe if needed.
To run tests at build time:
make checkctest --test-dir build --output-on-failuremeson test -C buildIf a test needs the installed environment, record it as a QEMU / hardware
verification step rather than in post_install.
Patches
Section titled “Patches”patch -p1 -d "$ZPKG_SRC/foo-$ZPKG_VERSION" \ < "$ZPKG_RECIPE_DIR/fix-build.patch"For the recipe file layout, see Recipes; for the workflow, see Packaging workflow.
