Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

20. Grep

GNU grep searches text for lines that match a pattern. Nearly every configure script, makefile and build script runs it. This step builds it without Perl-compatible regular expressions, because their library is not in the root yet. This page shows the commands of script/phases/10_bootstrap/066_grep.sh and explains them.

Source: the archive of the grep port
Installs into: build/fs/usr
Approximate build time: 0.4 SBU

Installation of grep

GREP_SRC=$(extract_port_source grep)

cd "$GREP_SRC"

./configure \
    --host=$KDOS_TARGET \
    --build=$(build-aux/config.guess) \
    --prefix=/usr \
    --disable-nls \
    --disable-perl-regexp

make
make DESTDIR=$SYSROOT install

script/phases/10_bootstrap/066_grep.sh, lines 23–35

The meaning of the configure options

--host=$KDOS_TARGET, --build=$(build-aux/config.guess), --prefix=/usr
A cross build, installed under /usr (see Part III).
--disable-nls
Build no message catalogues.
--disable-perl-regexp
Build without grep -P. Perl-compatible patterns need PCRE2, which is not in the root; -P from this build reports that it is not supported. Basic, extended and fixed-string patterns work as usual.

Contents of grep

Installed programs: grep, and egrep and fgrep, two shell scripts that warn that they are obsolescent and then run grep -E and grep -F.

The grep port’s page describes each program.

Built again later

The grep port, in 30_foundation, depends on pcre2 and passes --enable-perl-regexp in place of --disable-perl-regexp, so grep -P works and grep links libpcre2-8. Otherwise it is the same build, natively, and kpkg adopts the files this step installed.

See also