build: Move FTS feature check to m4 file with cache check too

This is to avoid checking for the FTS features in cross-compilation situations
where the check will fail and we've previously done the check anyway (knowing
it works). We use M4 caching for this.