O erro é bastante óbvio:
make[3]: flex: Command not found
O Mesa possui uma dependência de compilação em flex
, que pode ser instalado com:
sudo apt-get install flex
Para instalar todas as dependências de construção do Mesa de uma só vez, execute:
sudo apt-get build-dep mesa