8.17. Flex-2.6.4

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

Approximate build time: 0.1 SBU
Required disk space: 33 MB

8.17.1. Installation of Flex

Create the PKGBUILD for the Flex package with the following commands:

mkdir /sources/flex
cd /sources/flex
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>

pkgname="flex"
pkgver="2.6.4"
pkgrel="1"
pkgdesc="The Flex package contains a utility for generating programs that recognize patterns in text."
arch=('x86'
      'x86_64')
url="https://github.com/westes/flex"
license=('BSD3C'
         'custom')
groups=('core')
makedepends=('binutils'
             'coreutils'
             'gcc'
             'gettext'
             'grep'
             'make'
             'patch'
             'sed'
             'texinfo')
depends=('bash'
         'glibc'
         'm4')
checkdepends=('bison'
              'gawk')
optdepends=('help2man')
source=('https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz')
md5sums=('2882e3179748cc9f9c23ec593d6adc8d')

build(){
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr \
              --disable-static \
              --docdir="/usr/share/doc/${pkgname}-${pkgver}"
  make
}

check(){
  cd "${pkgname}-${pkgver}"
  make check
}

package(){
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  ln -svf flex "${pkgdir}/usr/bin/lex"
  ln -svf flex.1 "${pkgdir}/usr/share/man/man1/lex.1"
}
REALEOF

Prepare the build directory for the pacman user and build the package:

chown -R root:pacman .
chmod 2775 .
chmod 664 PKGBUILD
su pacman -c 'makepkg -L --nodeps'

Add the newly created package to the central package repository:

cp flex-2.6.4-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/flex-2.6.4-1-$(uname -m).pkg.tar.xz

Update the local cache and install the Flex package:

pacman -Syu
pacman -S flex --overwrite \* -dd --noconfirm

Finally, copy the source files into the source repository and clean up the build directory:

mkdir /srv/pacman/source/LFS/flex
cp PKGBUILD /srv/pacman/source/LFS/flex
cd /sources
rm -rf flex

8.17.2. Contents of Flex

Installed programs: flex, flex++ (link to flex), and lex (link to flex)
Installed libraries: libfl.so
Installed directory: /usr/share/doc/flex-2.6.4

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

flex++

An extension of flex, is used for generating C++ code and classes. It is a symbolic link to flex

lex

A symbolic link that runs flex in lex emulation mode

libfl

The flex library