6.22. Flex-2.5.35

The Flex package contains a utility for generating programs that recognize patterns in text.

6.22.1. Environment Settings

This package requires compiler variables to be set for the target in the environment.

export CC="${CLFS_TARGET}-gcc"
export CXX="${CLFS_TARGET}-g++"
export AR="${CLFS_TARGET}-ar"
export AS="${CLFS_TARGET}-as"
export RANLIB="${CLFS_TARGET}-ranlib"
export LD="${CLFS_TARGET}-ld"
export STRIP="${CLFS_TARGET}-strip"

6.22.2. Installation of Flex

Make sure that Flex doesn't try to include headers from /usr/include.

cp -v Makefile.in{,.orig}
sed "s/-I@includedir@//g" Makefile.in.orig > Makefile.in

When Cross Compiling the configure script does not does not determine the correct values for the following, Set the values manually:

cat > config.cache << EOF
ac_cv_func_malloc_0_nonnull=yes
ac_cv_func_realloc_0_nonnull=yes
EOF

Prepare Flex for compilation:

./configure --build=${CLFS_HOST} --host=${CLFS_TARGET} \
    --prefix=/usr --cache-file=config.cache

Compile the package:

make CC="${CC} -fPIC" libfl.a
make

Install the package:

make DESTDIR=${CLFS} install

There are some packages that expect to find the lex library in /usr/lib. Create a symlink to account for this:

ln -sfv libfl.a ${CLFS}/usr/lib/libl.a

A few programs do not know about flex yet and try to run its predecessor, lex. To support those programs, create a wrapper script named lex that calls flex in lex emulation mode:

cat > ${CLFS}/usr/bin/lex << "EOF"
#!/bin/sh
# Begin /usr/bin/lex

exec /usr/bin/flex -l "$@"

# End /usr/bin/lex
EOF
chmod -v 755 ${CLFS}/usr/bin/lex

6.22.3. Contents of Flex

Installed programs: flex and lex
Installed library: libfl.a libfl_pic.a

Short Descriptions

flex

A tool for generating programs that recognize patterns in text; it allows for the versatility to specify the rules for pattern-finding, eradicating the need to develop a specialized program

lex

A script that runs flex in lex emulation mode

libfl.a

The flex library