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:

Dependencies:

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