Run the following in a terminal emulator.
sudo apt install -y autoconf automake make help2man m4 gcc g++ gettext bison texinfo libtool
Clone the Flex repository
git clone https://github.com/westes/flex.git
CD inside the directory ``
cd flex/
Run these commands one after the other and check errors for missing packages:
sh
./autogen.sh
./configure
make -j4
sudo make install