8.31. om4 stage 2 6.7
om4 provides a compact m4 macro processor in the target userspace, using its custom configure flow with only supported options.
Input assumption:
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)
- yacc
- lex (flex)
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 "/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.
CC="clang" \
CFLAGS="$LWI_CFLAGS" \
LDFLAGS="$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 || {
awk '
{
print
if (!done && $0 == "#include <stdint.h>") {
print "#include <stdlib.h>"
done = 1
}
}
' parser.y > parser.y.tmp &&
mv parser.y.tmp parser.y
}
Generate the Tokenizer Source
lex -t tokenizer.l > tokenizer.c
Build om4
make -j1 CC="clang"
Install om4
make CC="clang" install
Command Explanations
cd /sources,tar -xf, andcd om4-...: Enter the staged om4 source tree.CC="clang",CFLAGS, andLDFLAGS: Configure om4 with the final target compiler and local tuning variables../configure --prefix=/system ... --enable-m4: Uses om4's custom configure script and installs the command asm4.grep -q ... || awk ...: Adds the missing<stdlib.h>include only when it is absent.lex -t tokenizer.l > tokenizer.c: Regenerates the tokenizer source from the lexer input.make -j1 CC="clang": Builds serially to avoid generated-source races.make CC="clang" install: Installs om4 into the configured target paths.