8.13. bsdgrep stage 2 master snapshot

Rebuild bsdgrep in the final target environment so grep-family tools match the completed userspace.

Input assumption: bsdgrep-master.zip is already present in /sources from the chapter 4 source staging step.

Source URL: https://github.com/arp242/bsdgrep/archive/refs/heads/master.zip

Snapshot note: this package is built from master, so upstream source content may change over time. The source archive staged by this book is pinned by scripts/sources.b2sums.

Upstream build note: upstream documents the standard make and make install flow. The Makefile installs grep, egrep, fgrep, and rgrep by default.

Licenses:

Dependencies:

bsdgrep is a FreeBSD-derived grep implementation for Linux. we need it to provide final target grep, egrep, fgrep, and rgrep command behavior for package builds and system use.

Extract and Enter the Source Tree

cd /sources
rm -rf bsdgrep-master
unzip -q bsdgrep-master.zip
cd bsdgrep-master

Apply Install Path Patch

sed -i '' \
    -e 's|${DESTDIR}${PREFIX}/bin|${DESTDIR}/system/binaries|g' \
    -e 's|${DESTDIR}${PREFIX}/share/man/man1|${DESTDIR}/system/documentation/man-pages/man1|g' \
    Makefile

Build bsdgrep

bsdgrep does not ship a configure script, so lbi_configure is not applicable here.
make $LWI_MAKE_FLAGS \
    CC=cc \
    CFLAGS="-O2 -DREG_STARTEND=0 $LWI_CFLAGS" \
    LDFLAGS="$LBI_CUSTOM_LDFLAGS"

Install bsdgrep

make install
After this step is complete, you can remove the extracted source directory and source archive from /sources if you do not plan to rebuild bsdgrep again.

Command Explanations