6.2. om4 6.7
om4 provides a compact m4 macro processor in the target userspace, using its custom configure flow with only supported options.
om4-6.7.tar.gz is already present in LBI_SOURCES from the chapter 4 source staging step.
Licenses:
- BSD-3-Clause
- ISC
Dependencies:
- musl (libc)
om4 is an OpenBSD-derived implementation of the m4 macro processor. we need it to provide a small, predictable m4 binary for package build flows in later chapters.
Extract and Enter the Source Tree
cd "$LBI_SOURCES"
tar -xf om4-6.7.tar.gz
cd om4-6.7
Configure om4 (Supported Flags Only)
This package uses a custom configure script and does not support the full flag set used by lbi_configure. It also insists on running a compiler test binary during configuration, so use a temporary static-link compiler command for configure, then switch back to the normal cross compiler for make.
CC="$LBI_ROOT/system/tools/bin/$LBI_TARGET-clang --target=$LBI_TARGET --sysroot=$LBI_ROOT -static" \
CFLAGS="--target=$LBI_TARGET --sysroot=$LBI_ROOT $LWI_CFLAGS" \
LDFLAGS="--target=$LBI_TARGET --sysroot=$LBI_ROOT $LBI_CUSTOM_LDFLAGS" \
./configure \
--prefix=/system \
--bindir=/system/binaries \
--mandir=/system/documentation/man-pages \
--enable-m4
Apply the Parser Compatibility Fix
Upstream parser.y calls exit(1) but does not include <stdlib.h>. Add it before building so modern Clang modes do not fail with an undeclared-function error.
grep -q '^#include <stdlib.h>$' parser.y || \
sed -i '/^#include <stdint.h>$/a #include <stdlib.h>' parser.y
Build and Install om4
make -j1 CC="$LBI_ROOT/system/tools/bin/$LBI_TARGET-clang"
make CC="$LBI_ROOT/system/tools/bin/$LBI_TARGET-clang" install DESTDIR="$LBI_ROOT"
Command Explanations
CC="$LBI_ROOT/system/tools/bin/$LBI_TARGET-clang --target=$LBI_TARGET --sysroot=$LBI_ROOT -static": Uses the pass-1 target-prefixed Clang compiler and forces static link forconfigureprobe binaries, so they can execute on a glibc host while still probing the target musl toolchain.CFLAGS="--target=$LBI_TARGET --sysroot=$LBI_ROOT $LWI_CFLAGS": Targets the configured triple and sysroot while allowing optional local C flag tuning.LDFLAGS="--target=$LBI_TARGET --sysroot=$LBI_ROOT $LBI_CUSTOM_LDFLAGS": Keeps link behavior on the target triple/sysroot and preserves optional local linker flags.--prefix=/system: Sets package install prefix under the target/systemtree.--bindir=/system/binaries: Installs the executable into the book's binary path layout.--mandir=/system/documentation/man-pages: Installs manual pages under the documentation tree.--enable-m4: Installs the program name asm4instead ofom4.grep -q ... || sed -i ... parser.y: Adds the missing<stdlib.h>include only if needed, keeping the source tree compatible with modern Clang behavior.make -j1 CC="$LBI_ROOT/system/tools/bin/$LBI_TARGET-clang": Reverts to the normal cross compiler command and serializes the build to avoidyaccmulti-target race conditions in this package's generatedMakefile.
The upstream script also accepts --enable-static, but that is not required for this pass.