8.15. Flex 2.6.4
Build and install Flex in the final target environment to provide lex-compatible scanner generation.
Input assumption: flex-2.6.4.tar.gz is already present in /sources from the chapter 4 source staging step.
Source URL: https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz
Upstream build note: the release tarball includes a generated configure script, generated parser and scanner sources, and prebuilt manual pages. Upstream documents the normal build flow as configure, make, and make install.
Tool note: Flex requires an m4 implementation that supports -P; chapter 6 installs om4 as the target m4 command.
Licenses:
- BSD-style Flex license
Dependencies:
- musl (libc)
- m4
- make
Flex is a fast lexical analyzer generator. we need it to provide final target flex, lex, and libfl support for packages that generate scanners during their build.
Extract and Enter the Source Tree
cd /sources
tar -xf flex-2.6.4.tar.gz
cd flex-2.6.4
Configure Flex
lbi_configure \
--docdir=/system/documentation/flex \
--disable-static \
--enable-shared \
--disable-nls
Build Flex
make $LWI_MAKE_FLAGS
Install Flex
make install
Install lex Compatibility Links
ln -sf flex /system/binaries/lex
ln -sf flex.1 /system/documentation/man-pages/man1/lex.1
/sources if you do not plan to rebuild Flex again.
Command Explanations
cd /sources,tar -xf, andcd flex-...: Enter the staged Flex source tree.lbi_configure: Applies the book's/systeminstall layout.--docdir=/system/documentation/flex: Places package documentation in the documentation tree.--disable-staticand--enable-shared: Build shared libraries without static archives.--disable-nls: Avoids gettext/native language support.make $LWI_MAKE_FLAGSandmake install: Build and install Flex.ln -sf flex ... lexandln -sf flex.1 ... lex.1: Provide traditional lex command and manual-page aliases.