6.7. sbase git snapshot
sbase provides a compact portable Unix utility set for the early target userspace.
Input assumption: sbase-c1341583c963.tar.gz is already present in LBI_SOURCES from the chapter 4 source staging step.
Source note: this archive is generated by scripts/fetch-sources.sh from upstream https://git.suckless.org/sbase at commit c1341583c96307cb0e6152c963ed23c4d56a4278.
Licenses:
- MIT/X Consortium-style license
Dependencies:
- musl (libc)
- make (host)
- awk (host)
- yacc-compatible parser generator, such as
yaccorbyacc(host)
sbase is a compact portable Unix utility collection from suckless. we need it to provide the early target command set used by later build, install, and troubleshooting steps.
Extract and Enter the Source Tree
cd "$LBI_SOURCES"
tar -xf sbase-c1341583c963.tar.gz
cd sbase-c1341583c963
Build sbase
Build note: sbase builds one generated
bc source with a yacc-compatible parser generator. Prefer yacc when present, and fall back to byacc.
YACC=${YACC:-yacc}
if ! command -v "$YACC" >/dev/null 2>&1 && command -v byacc >/dev/null 2>&1; then
YACC=byacc
fi
make $LWI_MAKE_FLAGS \
YACC="$YACC" \
CC="$LBI_ROOT/system/tools/bin/$LBI_TARGET-clang" \
AR="$LBI_ROOT/system/tools/bin/$LBI_TARGET-ar" \
RANLIB="$LBI_ROOT/system/tools/bin/$LBI_TARGET-ranlib" \
CFLAGS="--target=$LBI_TARGET --sysroot=$LBI_ROOT $LWI_CFLAGS" \
LDFLAGS="--target=$LBI_TARGET --sysroot=$LBI_ROOT $LBI_CUSTOM_LDFLAGS"
Install sbase
make install \
DESTDIR="$LBI_ROOT" \
PREFIX=/system \
MANPREFIX=/system/documentation/man-pages
install -d "$LBI_ROOT/system/binaries"
if [ -d "$LBI_ROOT/system/bin" ]; then
mv -f "$LBI_ROOT/system/bin/"* "$LBI_ROOT/system/binaries/"
rmdir "$LBI_ROOT/system/bin"
fi
ln -sf xinstall "$LBI_ROOT/system/binaries/install"
Command Explanations
YACC=${YACC:-yacc}: Uses an existingYACCsetting when present, otherwise defaults toyacc.command -v "$YACC" ... && command -v byacc ...: Falls back tobyaccwhen the default yacc-compatible parser generator is not available.make $LWI_MAKE_FLAGS ...: Builds sbase using the shared make parallelism setting.YACC="$YACC": Passes the selected parser generator into sbase's generated-source rules.CC="$LBI_ROOT/system/tools/bin/$LBI_TARGET-clang": Builds target programs with the target-prefixed Clang compiler.ARandRANLIB: Use the matching target-prefixed LLVM archive tools for any static archives built by sbase.CFLAGS="--target=$LBI_TARGET --sysroot=$LBI_ROOT $LWI_CFLAGS": Targets the selected triple, reads headers and libraries from the target root, and preserves local C flag tuning.LDFLAGS="--target=$LBI_TARGET --sysroot=$LBI_ROOT $LBI_CUSTOM_LDFLAGS": Keeps link steps pointed at the target sysroot while preserving local linker flag tuning.make install DESTDIR="$LBI_ROOT" PREFIX=/system MANPREFIX=/system/documentation/man-pages: Installs under the target/systemlayout and places manual pages in the book's documentation tree.install -d "$LBI_ROOT/system/binaries": Ensures the final binary directory exists before moving upstream's default output.mv -f "$LBI_ROOT/system/bin/"* "$LBI_ROOT/system/binaries/": Moves programs from upstream's defaultbindirectory into the book'sbinariesdirectory.rmdir "$LBI_ROOT/system/bin": Removes the now-empty upstream default directory so the target tree keeps the intended layout.ln -sf xinstall "$LBI_ROOT/system/binaries/install": Provides the expectedinstallcommand name from sbase'sxinstallbinary.