Make configure fail if it doesn't find flex.

Fixes #3859.